How about just putting in in a separate thread and that way you could let the thread that calls consumer.Receive() just hang until another message arrives while your main thread does some other work?
robottaway wrote: > > I am guessing that the Recieve function on the ActiveMQ message consumer > in the NMS api should return null when no messages are on a queue. I am > not seeing this. I try to check for messages after receive, making sure > that they are not null. What happens is that execution stops at the > consumer.Receive() call, and does not move forward until a message comes > into the queue. > > What I am trying to do is the following: I have a windows service that > will consume messages from a queue. When it starts up I want to try and > read all messages on the queue. Once the initial messages are done being > read I want to have the consumer stop, and another consumer with a > MessageListener takes over. I register the MessageListener on another > consumer so that any new messages that come into the queue will be read > asynchronously. > > I can make one or the other work, but not both. This is because the > Receive function does not return when there are no messages on the queue I > am reading from. > -- View this message in context: http://www.nabble.com/NMS-C--client-Recieve-not-timing-out-tf2497328.html#a6978831 Sent from the ActiveMQ - User mailing list archive at Nabble.com.
