ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Queue consumer with selector consume message not matched

Post new topic  Reply to topic
 Queue consumer with selector consume message not matched « View previous topic :: View next topic » 
Author Message
henry_chuo1
PostPosted: Thu Nov 13, 2014 10:21 pm    Post subject: Queue consumer with selector consume message not matched Reply with quote

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
View user's profile Send private message
calanais
PostPosted: Fri Nov 14, 2014 2:20 am    Post subject: Reply with quote

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
View user's profile Send private message
henry_chuo1
PostPosted: Fri Nov 14, 2014 2:24 am    Post subject: Reply with quote

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
View user's profile Send private message
calanais
PostPosted: Fri Nov 14, 2014 2:42 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Fri Nov 14, 2014 2:47 am    Post subject: Re: Queue consumer with selector consume message not matched Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
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
View user's profile Send private message Send e-mail
henry_chuo1
PostPosted: Fri Nov 14, 2014 2:51 am    Post subject: Reply with quote

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
View user's profile Send private message
henry_chuo1
PostPosted: Fri Nov 14, 2014 2:53 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Fri Nov 14, 2014 2:56 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Queue consumer with selector consume message not matched
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.