Author |
Message
|
HenriqueS |
Posted: Tue Jan 29, 2008 10:46 am Post subject: Retrieving only the message with matching MsgId |
|
|
 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 |
|
 |
jefflowrey |
Posted: Tue Jan 29, 2008 11:15 am Post subject: |
|
|
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 |
|
 |
RogerLacroix |
Posted: Tue Jan 29, 2008 9:26 pm Post subject: |
|
|
 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 |
|
 |
HenriqueS |
Posted: Wed Jan 30, 2008 1:29 pm Post subject: |
|
|
 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 |
|
 |
jefflowrey |
Posted: Wed Jan 30, 2008 1:39 pm Post subject: |
|
|
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 |
|
 |
HenriqueS |
Posted: Wed Jan 30, 2008 2:12 pm Post subject: |
|
|
 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 |
|
 |
|