You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by Stephen Vincent <St...@sas.com> on 2010/12/10 17:53:23 UTC

JMS java client having trouble receiving with message selector

       My JMS java client creates one consumer with a message selector and works fine when receiving messages from WebSphere MQ.   But seldom works when receiving from a queue on ActiveMQ 5.3.1 and 5.4.1.  Most of the time I don't get any messages.  I can consistently get it to work *IF* I am stepping through the java code using the debugger in Eclipse and I have "?jms.prefetchPolicy.queuePrefetch=1" added to my jndi provider URL.  I only have one consumer, so I don't think it is a flow control or maxPageSize issue.  However, given that it works when under the debugger, then it may be something like that.

       In my test case, I put 50 messages on the queue, where every third message should match on my selector, which compares against JMSCorrelationID.  (eg. JMSCorrelationID = '223456789ABCDEF012345622' )

        I have seen it work a few times outside of the debugger, but it fails most of the time.  I am currently running this test case on Windows XP, Java spec version 1.6.0_21, class version 50.0.

        I am able to use the activemq-admin command line tool to get messages using a selector.  For example:

    activemq-admin browse --amqurl tcp://localhost:61616 --msgsel " JMSCorrelationID = '223456789ABCDEF012345622'" request

However, my JMS compliant Java application is having trouble doing it.  Obviously my app is doing something different.  If you have any ideas of what might be causing this, please let me know.

Thanks,
sv

sasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasas
Stephen Vincent
Platform R&D
Tel: + 1 919 531 7556
stephen.vincent@sas.com
SAS ... THE POWER TO KNOW




Re: JMS java client having trouble receiving with message selector

Posted by "Steve.V." <st...@sas.com>.
Gary Tully responded to my in the user forum and provide me with the info I
needed to find my mistake.  Below is the follow-up I sent to the user forum
describing my mistake.

------------------

…snip…
> It does not poll the broker for messages unless prefetch is 0.
…snip…


Gary,

	Thank you Gary.  Not only does prefetch=0 allow me to get the messages, but
it also caused me to inspect my code given that new knowledge.  I now
realize I told a fib when I said I was only creating one consumer.  I had
forgotten that by default, I am creating a consumer without a message
selector.  Later, if my user wants a message and specifies a message
selector, I create a new consumer with the message selector. The creation of
that first plain consumer is causing my problem.  I assume the messages were
dispatched to it upon creation; such that when I subsequently create the
second consumer with the message selector, it doesn't see the messages that
were already dispatched to that first consumer.  The problem is circumvented
by setting prefetch=0, but I should should fix my app by refraining from
creating that first "default" consumer.  I assume my app and test case
worked when using WebSphere MQ because I assume no messages are being
dispatched to the consumer upon its creation.  I guess WebSphere MQ waits
until the first receive before dispatching messages. 

Thank you very much for reading my post and providing me with that valuable
info.  I sincerely appreciate it.

Thanks,
sv

sasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasas
Stephen Vincent

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/JMS-java-client-having-trouble-receiving-with-message-selector-tp3070652p3089423.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.