activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: Problem with Selector
Date Tue, 26 Aug 2008 07:44:57 GMT
2008/8/26 Jecsiac <>:
> 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

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

Just replace receiveNoWait() with receive(2000L) and it should work fine


Open Source Integration

View raw message