SlimMessageBus icon indicating copy to clipboard operation
SlimMessageBus copied to clipboard

Consumer Filtering

Open t11omas opened this issue 7 months ago • 4 comments

We have a scenario were we use the same queue for multiple message types. There is a header on the message to define which messageType it is.

It would be useful to filter consumers based on header values. For example

  cbb.Consume<MyMessageType>(x => x
     .Queue("some-queue")
     .Filter(x => x.Header.ResourceType == nameof(MyMessageType))
      .WithConsumer<MyMessageTypeConsumer>()

  cbb.Consume<MyMessageType2>(x => x
     .Queue("some-queue")
     .Filter(x => x.Header.ResourceType == nameof(MyMessageType2))
      .WithConsumer<MyMessageType2Consumer>()

t11omas avatar May 22 '25 05:05 t11omas

Would the filtering be based on haders alawys in your case? What transport are you using?

zarusz avatar May 22 '25 19:05 zarusz

Yes just the headers we would be filtering upon and its SQS for this scenario.

t11omas avatar May 23 '25 06:05 t11omas

I could make it happen. Is there any urgency on this? Also, happy to accept a PR in case you want to help.

zarusz avatar May 26 '25 07:05 zarusz

Its not urgent, we have worked around it for the moment, its just an observation/potential improvement

t11omas avatar May 28 '25 06:05 t11omas

Morning: added a proposal PR for this.

t11omas avatar Dec 02 '25 07:12 t11omas

Closed via #447

zarusz avatar Dec 06 '25 21:12 zarusz