Author |
Message
|
henry_chuo1 |
Posted: Thu Nov 13, 2014 10:21 pm Post subject: Queue consumer with selector consume message not matched |
|
|
Novice
Joined: 13 Nov 2014 Posts: 11
|
Hi all,
We developed an Java application in which multiple clients connect to a server with MQ 7.0. Each client has consumer with selector on session id eg. JMSCorrelationID='050_14133431' on shared queues, in which server set session id on messages by setJMSCorrelationID( ) sent to a particular client. Client session ids are unique. It works fine most of the time. However, we just found some messages with client A sessionId are consumed by client B surprisingly. I checked the logs and confirmed that each client only create consumer with selector on its sessionId. In my understanding, consumer with only consume messages that match the selector criteria. One thing to note is that I used read ahead feature as our application use non persistent messages. Any idea why this happen? Is it caused by read ahead? Any help or hint is appreciated. Thanks a lot in advance.
public MessageConsumer getP2PConsumer(String destination, String selector) throws Exception
{
MessageConsumer consumer = null;
if(consumers.get(destination)!=null)
{
consumer = consumers.get(destination);
if((selector==null && consumer.getMessageSelector()==null)
|| (selector!=null && consumer.getMessageSelector()!=null && selector.equals(consumer.getMessageSelector())))
return consumers.get(destination);
}
Destination dest = session.createQueue(destination);
((MQDestination)dest).setReadAheadAllowed(WMQConstants.WMQ_READ_AHEAD_ALLOWED_ENABLED);
consumer = session.createConsumer(dest, selector);
consumers.put(destination, consumer);
return consumer;
} |
|
Back to top |
|
 |
calanais |
Posted: Fri Nov 14, 2014 2:20 am Post subject: |
|
|
Apprentice
Joined: 12 Mar 2010 Posts: 32
|
So to clarify you have 2 consumers with two different selectors - based on correlation ID but with different values.
There are a spread of messages on the queue, and sometimes a consumer with selector JMSCorrelationID="one" gets messages with a JMSCorrelationID of "two"?
ReadAhead should not be affecting this.
I'd be careful about using the phrase 'session id' - reason being that JMS has a 'session' concept but no ID.. I understand that this referring to your application concepts but maybe worth being explicit.
Matthew |
|
Back to top |
|
 |
henry_chuo1 |
Posted: Fri Nov 14, 2014 2:24 am Post subject: |
|
|
Novice
Joined: 13 Nov 2014 Posts: 11
|
@calanais
Thanks for reply. Yes, that is exactly scenario I faced now. Regarding 'session', the session id is one string generated by our application.
The issue surprise me as I don't expect to this to happen. Any idea or possible hint would help.
Thanks a lot. |
|
Back to top |
|
 |
calanais |
Posted: Fri Nov 14, 2014 2:42 am Post subject: |
|
|
Apprentice
Joined: 12 Mar 2010 Posts: 32
|
I would do the following:
Check that you've the lastest JMS Client.. you didn't say what the CSD level was.
Have you tired without read-ahead.. just in case this the problem.
Might be worth validating if a general selector such as colour=red would have the same problem.
If the problem exists on a later CSD - I would suggest it's time to open a IBM problem. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Nov 14, 2014 2:47 am Post subject: Re: Queue consumer with selector consume message not matched |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
henry_chuo1 wrote: |
Code: |
public MessageConsumer getP2PConsumer(String destination, String selector) throws Exception
{
MessageConsumer consumer = null;
if(consumers.get(destination)!=null)
{
consumer = consumers.get(destination);
if((selector==null && consumer.getMessageSelector()==null)
|| (selector!=null && consumer.getMessageSelector()!=null && selector.equals(consumer.getMessageSelector())))
return consumers.get(destination);
}
Destination dest = session.createQueue(destination);
((MQDestination)dest).setReadAheadAllowed(WMQConstants.WMQ_READ_AHEAD_ALLOWED_ENABLED);
consumer = session.createConsumer(dest, selector);
consumers.put(destination, consumer);
return consumer;
} |
|
And you're absolutely, positively sure you can't have a consumer with a null or empty selection string?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
henry_chuo1 |
Posted: Fri Nov 14, 2014 2:51 am Post subject: |
|
|
Novice
Joined: 13 Nov 2014 Posts: 11
|
Thanks. You remind me sth. Our MQ server was patched up to 7.0.1.9. However, my client still use jars of WebSphere MQ classes for Java Message Service(7.0.1.6) and WebSphere MQ classes for Java(7.0.1.6).
Do you think it is the cause?
The scenario is difficult to simulate, just happen very rarely. |
|
Back to top |
|
 |
henry_chuo1 |
Posted: Fri Nov 14, 2014 2:53 am Post subject: |
|
|
Novice
Joined: 13 Nov 2014 Posts: 11
|
@fjb_saper
Thanks for reply. Yes, should be 100% sure no consumer having a null or empty selection string on the queues in question. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Nov 14, 2014 2:56 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
henry_chuo1 wrote: |
Thanks. You remind me sth. Our MQ server was patched up to 7.0.1.9. However, my client still use jars of WebSphere MQ classes for Java Message Service(7.0.1.6) and WebSphere MQ classes for Java(7.0.1.6).
Do you think it is the cause?
The scenario is difficult to simulate, just happen very rarely. |
It will happen every time your criteria is satisfied with a null selector or empty selector.
Your if condition does not necessarily do what you might have meant it to do...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|