BTW are you trying to do request/response over JMS - is that why you're numbering your messages and trying to receive a specific one back?
http://activemq.apache.org/how-should-i-implement-request-response-with-jms.html 2008/8/26 James Strachan <[EMAIL PROTECTED]>: > 2008/8/26 Jecsiac <[EMAIL PROTECTED]>: >> >> Hi, I have a problem when using selector in ActiveMQ 5.1.0. >> >> I set a property named 'SomeId' on every Message sent to the queue, and >> every Message has a different value of that property (the value is just the >> order of the message sent to the queue, for example, for the first message >> sent to the queue, it's SomeId is 1, and for the second, is 2, and so on. >> And here, I use this mechanism is just for describing the problem easily. >> It's not the thing that I want to realize). When I use selector to receive >> message from the queue, I get a strange result: I send 2000 messages to the >> queue, and when I write: >> >> QueueReceiver receiver = session.createReceiver(queue, 'SomeId = 5'); >> receiver.receiveNoWait(); >> >> I can get the message. But when I write: >> >> QueueReceiver receiver = session.createReceiver(queue, 'SomeId = 200'); >> receiver.receiveNoWait(); >> >> I just get null. What's the problem? I do the just same thing on JBossMQ, >> everything is right, no problem. So I just do not known what's going wrong. > > receiveNoWait() is not meant to wait for a message to arrive. In > ActiveMQ creating a receiver does not block until messages are > received. > > i.e. its not really JMS compliant to use receiveNoWait() and not > expect nulls to come back if you've not really left much time for the > JMS provider to actually find the messages and return them over the > network. > > Just replace receiveNoWait() with receive(2000L) and it should work fine > > > -- > James > ------- > http://macstrac.blogspot.com/ > > Open Source Integration > http://open.iona.com > -- James ------- http://macstrac.blogspot.com/ Open Source Integration http://open.iona.com