Sonic MQ: Consuming certain messages from a queue

Posted by nweddle on 12-May-2009 09:35

I am using Sonic MQ 7.0

I am browsing through a queue every 60 seconds and doing database look-ups on each message I find. When I find what I am looking for in the database, I want to consume the corresponding message from the queue.

Do I have to consume each message to get at the one I want, and then publish the others back to the queue? Should I set a header property and use a selector?

Thanks!

Nathan

All Replies

Posted by Bill Wood on 26-Oct-2009 12:55

Really you have three options here

  • Use a QueueBrowser to see the message in advance, and then when you find the one you want, consume it by creating a new Message Consumer that has a selector with "JMSMessageID="
    • This is good but only if you have a low message rate as the selector is not very efficient when you are getting one message in a queue.
  • Use SINGLE_MESSAGE_ACKNOWLEGE.  When you get messages you want to consume, ACK them.   When you are done with the session, close it and the un-acked messages will go back to the queue.
    • This works, but you will have all the messages that are un-acked in memory.  Also, no other consumer can see them.  I would do this if you had a high probability that you can hold all the messages in memory, and ack them relatively quickly.
  • Look at the messages.  Use the AcknowledgeAndForward to send them to a second queue (possibly send them back to the one you are on, so they go back to the end.  The ones you want to Ack, do that.

Good luck.

This thread is closed