How to receive a message from ActiveMQ broker by it's message id?

427 views Asked by At

We consume a list of messages from the queue inside ActiveMQ broker and present it to the user so the user can select one message, we are using the .net client implementation based on AMQP.Net Lite (.net 2.1).

AMQ queue messages

If the user wants to select a specific message from the queue, not the one which is the next to consume from the queue, is there any possibility to access that message by the 'MessageId' parameter or some other property?

Something like the code bellow :

Message msgToSend = new Message();
msgToSend.Properties = new Properties() { MessageId = "8589942532"};
receiver.Accept(msgToSend);

The list of messages the user can see from the queue are not accepted so they are still visible in the queue. The idea is to accept the message when the user performese a specific action like clicking a 'save' button.

1

There are 1 answers

0
Ievgen Popovych On

You can create additional consumer with filter expression, which naturally would filter by message ID, to receive that message. After receiving the message, this consumer would have to go as it would be of no use.

BTW, you can also use non-destructive queues or consumers to browse the queue without removing messages from it (at least this is available in Artemis, not sure about ActiveMQ Classic).