Search code examples
c#queuerabbitmqamqp

C#: Retrieve particular record from RabbitMQ queue


I am looking forward to retrieve a particular message from the RabbitMQ queue. Can somebody please guide me on this.

I checked this Retrieve messages from RabbitMQ queue(s)

But above ticket was fr PHP. I want to retrieve one particular message from queue using C# .net.

Edit: Attached ticket doesn't solved my problem. @zaq178miami if you think so then can you please provide me sample line of code to do same?


Solution

  • You can't. RabbitMQ does not support the "selective consumer" pattern.

    You can only retrieve messages from a queue in the order in which they appear in the queue: First-In-First-Out.

    If you need a specific message to go to a specific consumer, use exchanges and routing keys to ensure that message goes to a queue where that consumer will receive it.

    See my blog post on this subject for more detail: http://derickbailey.com/2015/07/22/airport-baggage-claims-selective-consumers-and-rabbitmq-anti-patterns/