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 API Support » How to browse a message using MessageID

Post new topic  Reply to topic
 How to browse a message using MessageID « View previous topic :: View next topic » 
Author Message
crayon_coco
PostPosted: Mon Mar 14, 2005 2:32 am    Post subject: How to browse a message using MessageID Reply with quote

Apprentice

Joined: 08 Oct 2003
Posts: 33

If i have the Message ID how do i browse to get the correct the message from the queue with the message ID without removing it from the queue
Back to top
View user's profile Send private message
bower5932
PostPosted: Mon Mar 14, 2005 7:25 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

You specify on the MQGMO.options that you want to browse the message. Look in the Application Programming Reference for:

MQGMO_BROWSE_FIRST
MQGMO_BROWSE_NEXT

You'll also find information on locking (MQGMO_LOCK).
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
crayon_coco
PostPosted: Mon Mar 14, 2005 4:55 pm    Post subject: Reply with quote

Apprentice

Joined: 08 Oct 2003
Posts: 33

So does it mean that i have to loop through the queue and find the message that i want? how do i do it with the MessageID that i have?
Back to top
View user's profile Send private message
bob_buxton
PostPosted: Tue Mar 15, 2005 1:28 am    Post subject: Reply with quote

Master

Joined: 23 Aug 2001
Posts: 266
Location: England

You set the messageid you want in the MQMD prior to issuing your browse first call and it will return the first message with that id. Subsequent browse next calls could be used to return any messages with duplicate message ids.
_________________
Bob Buxton
Ex-Websphere MQ Development
Back to top
View user's profile Send private message
crayon_coco
PostPosted: Tue Mar 15, 2005 1:55 am    Post subject: Reply with quote

Apprentice

Joined: 08 Oct 2003
Posts: 33

i tried that and i works for the Message that is in the queue, when i set the MQMD to a messageid that is not exist in the queue it will just return any message that is in the last in the queue
Back to top
View user's profile Send private message
bower5932
PostPosted: Tue Mar 15, 2005 7:18 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

Check out the matching options. There is an option that indicates you want to match based on message id.
Code:

#define MQMO_MATCH_MSG_ID         0x00000001
#define MQMO_MATCH_CORREL_ID      0x00000002
#define MQMO_MATCH_GROUP_ID       0x00000004
#define MQMO_MATCH_MSG_SEQ_NUMBER 0x00000008
#define MQMO_MATCH_OFFSET         0x00000010
#define MQMO_MATCH_MSG_TOKEN      0x00000020
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
malammik
PostPosted: Tue Mar 15, 2005 8:31 am    Post subject: Reply with quote

Partisan

Joined: 27 Jan 2005
Posts: 397
Location: Philadelphia, PA

Here is a sample you can modify to return base MQMessage class.
public QFlexMessage browseMessageById(String queueName, byte[] messageId) {
int openOptions = MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQOO_BROWSE | MQC.MQOO_INQUIRE;
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = MQC.MQGMO_BROWSE_NEXT | MQC.MQGMO_FAIL_IF_QUIESCING;

// Set message id.
MQMessage msg = new MQMessage();
msg.messageId = messageId;

MQQueue queue = null;
MQQueueManager qmConnection = null;
QFlexMessage qmessage = null;
try {
qmConnection = MqPcfUtil.getMQQueueManagerConnection(qmanager);
queue = qmConnection.accessQueue(queueName, openOptions);

// Obtain a message by id.
queue.get(msg, gmo);
qmessage = new QFlexMessage(msg);
}
catch (MQException e) {
if (e.reasonCode == MQException.MQRC_NO_MSG_AVAILABLE) {
logger.info("message is no longer on the queue");
}
else {
logger.error("Failed to access queue :" + queueName, e);
}
}
finally {
try {
if (queue != null && queue.isOpen()) {
queue.close();
}
}
catch (MQException mqe) {
logger.error(mqe);
}
try {
if (qmConnection != null && qmConnection.isOpen()) {
qmConnection.disconnect();
}
}
catch (MQException mqe) {
logger.error(mqe);
}
}
return qmessage;
}
_________________
Mikhail Malamud
http://www.netflexity.com
http://groups.google.com/group/qflex
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » How to browse a message using MessageID
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.