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 » Retrieving only the message with matching MsgId

Post new topic  Reply to topic
 Retrieving only the message with matching MsgId « View previous topic :: View next topic » 
Author Message
HenriqueS
PostPosted: Tue Jan 29, 2008 10:46 am    Post subject: Retrieving only the message with matching MsgId Reply with quote

Master

Joined: 22 Sep 2006
Posts: 235

Folks,

I want to retrieve only the message with the supplied MsgId, but I am getting the oldest one in the queue instead. Is anything wrong in the code? I tried changing the delivery sequence from FIFO to Priority but stills the problem.

Maybe my homemade getByteArrayFromHexString() method...

Code:

public String getMessage(String qm, String qn, String Msgid){
        String message = "";
        try {   
                MQQueueManager qMgr = new MQQueueManager(qm, properties);
                int openOptions = MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INPUT_SHARED;

                //Now specify the queue that we wish to open, and the open options...
                MQQueue queue = qMgr.accessQueue(qn, openOptions);

                MQMessage retrievedMessage = new MQMessage();
               
                //Set the get message options...
                MQGetMessageOptions gmo = new MQGetMessageOptions(); //accept the defaults
                if(Msgid != null){
                   gmo.options = MQC.MQMO_MATCH_MSG_ID;
                   gmo.msgToken = getByteArrayFromHexString(Msgid);
                }
               
                //get the message off the queue...
                queue.get(retrievedMessage, gmo);
                retrievedMessage.characterSet = ((Integer) properties.get("mqcharset")).intValue();

                int length = retrievedMessage.getMessageLength();
                //System.out.print("length is: " + length);
                message = retrievedMessage.readString(length /((Integer)properties.get("mqcharlength")).intValue());
                //Close the queue...
                queue.close();
                //Disconnect from the queue manager
                qMgr.disconnect();
                return(message);
        }
        //If an error has occurred in the above,try to identify what went wrong
        //Was it an MQSeries error?
        catch (MQException ex)
        {...}

_________________
HenriqueS
Certified Websphere MQ 6.0 System Administrator
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Jan 29, 2008 11:15 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You have to set the MsgId on the MQMessage you pass in.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Tue Jan 29, 2008 9:26 pm    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3264
Location: London, ON Canada

FYI
Code:
if(Msgid != null)
{
   gmo.options = MQC.MQMO_MATCH_MSG_ID;
   retrievedMessage.messageId = getByteArrayFromHexString(Msgid);
}


Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
HenriqueS
PostPosted: Wed Jan 30, 2008 1:29 pm    Post subject: Reply with quote

Master

Joined: 22 Sep 2006
Posts: 235

Sorry, I did not get it...

RogerLacroix wrote:
FYI
Code:
if(Msgid != null)
{
   gmo.options = MQC.MQMO_MATCH_MSG_ID;
   retrievedMessage.messageId = getByteArrayFromHexString(Msgid);
}


Regards,
Roger Lacroix
Capitalware Inc.

_________________
HenriqueS
Certified Websphere MQ 6.0 System Administrator
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jan 30, 2008 1:39 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

HenriqueS wrote:
Sorry, I did not get it...

Quote:
if(Msgid != null){
gmo.options = MQC.MQMO_MATCH_MSG_ID;
gmo.msgToken = getByteArrayFromHexString(Msgid);
}


versus

Quote:
if(Msgid != null)
{
gmo.options = MQC.MQMO_MATCH_MSG_ID;
retrievedMessage.messageId = getByteArrayFromHexString(Msgid);
}

_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
HenriqueS
PostPosted: Wed Jan 30, 2008 2:12 pm    Post subject: Reply with quote

Master

Joined: 22 Sep 2006
Posts: 235

Oh, sorry for that! Thanks for the attention.
_________________
HenriqueS
Certified Websphere MQ 6.0 System Administrator
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Retrieving only the message with matching MsgId
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.