0

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?

Community
  • 1
  • 1
Freelancer
  • 73
  • 9
  • It doesn't matter what language you use, this is about queue as a data type concept rather than language or platform. That answer still true for you too. You may want to search for "rabbitmq fifo" here on SO or on google to see more related questions. – pinepain Feb 20 '16 at 10:22
  • Possible duplicate of [Retrieve messages from RabbitMQ queue(s)](http://stackoverflow.com/questions/2215086/retrieve-messages-from-rabbitmq-queues) – pinepain Feb 20 '16 at 10:23
  • P.S. I've added an answer to [that question which you referred to](http://stackoverflow.com/questions/2215086/retrieve-messages-from-rabbitmq-queues). I hope it can answer all kind of such questions. I mark this one as duplicate for the same reason - it just mention different language but focuses on the same thing like that question. – pinepain Feb 20 '16 at 10:46

1 Answers1

1

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/

Derick Bailey
  • 72,004
  • 22
  • 206
  • 219
  • Ok..Let's say if i have 10000 messages in queue and i have to retrieve 9001 then am i suppose to scan through all 9000 messages?? Do you have any better way around? – Freelancer Feb 21 '16 at 07:23
  • no - that's a terrible thing to do and will cause performance and other problems. the better way is to not put yourself in that situation. design your exchanges, queues and bindings so that your consumer is able to process all of the messages in the queue that is reads from. – Derick Bailey Feb 21 '16 at 20:24