Author |
Message
|
spoimala |
Posted: Wed Feb 20, 2002 4:47 am Post subject: |
|
|
Novice
Joined: 05 Feb 2002 Posts: 10
|
I'm doing a component that reads and writes messages to/from a queue (C++ MQI API).
When I write a message to queue, how do I know, what is the ID of that message so I can read it from queue?
How long messages stay in queue? If I put three messages tu queue, can I read them in reverse order (or whatever order)? |
|
Back to top |
|
 |
jhalstead |
Posted: Wed Feb 20, 2002 5:29 am Post subject: |
|
|
 Master
Joined: 16 Aug 2001 Posts: 258 Location: London
|
As you pass the MQMQ structure into MQPUT it is populated by MQSeries, so if you look at MQMD.MsgId after putting a message you should have the message id available for use.
The Application programming Guide and Application Programming reference are essential reads to assist in MQSeries development.
http://www-4.ibm.com/software/ts/mqseries/library/mqpdfs.html
Jamie |
|
Back to top |
|
 |
mqonnet |
Posted: Wed Feb 20, 2002 6:32 am Post subject: |
|
|
 Grand Master
Joined: 18 Feb 2002 Posts: 1114 Location: Boston, Ma, Usa.
|
I'm doing a component that reads and writes messages to/from a queue (C++ MQI API).
When I write a message to queue, how do I know, what is the ID of that message so I can read it from queue?
How long messages stay in queue? If I put three messages tu queue, can I read them in reverse order (or whatever order)?
As explained already, you get the message id after the call to MQPUT. The md.MsgId has the message id generated by the Queue manager for you. Remember you need to call MQPUT with NEW_MSG_ID, so that each message has a unique message id generated by the qm.
A message stays on the queue until it is retrieved from the Queue, Destructively, or is expired. This is the most common scenario.
You can retrive a message in any order you wish in as many ways. In your case, since you already have message id's for all the messages you could use messageid as the key to retrieve the messages.
Cheers
Kumar
_________________ IBM Certified WebSphere MQ V5.3 Developer
IBM Certified WebSphere MQ V5.3 Solution Designer
IBM Certified WebSphere MQ V5.3 System Administrator |
|
Back to top |
|
 |
spoimala |
Posted: Wed Feb 20, 2002 11:28 pm Post subject: |
|
|
Novice
Joined: 05 Feb 2002 Posts: 10
|
Okay, thanks guys.
But one problem. How can I access this MQMD structure as it's protected member of IMqMessage? I don't find a method in Message class to set/get these members.
(They told in that book, I should set these to null in order to have unique IDs). Where do I set the NEW_MSG_ID?
You guys speak about calling MQPUT it means calling ImqQueue.put? It takes one or two parameters: ImqMessage and ImqPutMessageoptions. In PMO, there are MsgID.
Thanks. |
|
Back to top |
|
 |
spoimala |
Posted: Wed Feb 20, 2002 11:52 pm Post subject: |
|
|
Novice
Joined: 05 Feb 2002 Posts: 10
|
In one book (http://www-3.ibm.com/software/ts/mqseries/txppacs/supportpacs/imqi.pdf) they say that there are methods setCorrelation id and set/getMessageID (but no getCorrelation ID).
But those methods are not available in my API. Are there many version of MQI (I didn't find a version number in the header files) |
|
Back to top |
|
 |
spoimala |
Posted: Thu Feb 21, 2002 1:42 am Post subject: |
|
|
Novice
Joined: 05 Feb 2002 Posts: 10
|
Strange, I don't find those methods in header file (neither does the intellisense of Visual Studio) but compiler doesn't complain when I add the methods...
Okay, now I have access the message and correlation IDs, but they are ImqBinary. Is it impossible to just use integers?
(I have to marshal them over COM and use from C#)
Are there any good tutorials or samples how to handle these things?
I found one good example, but it uses ImBinary internally
(http://www.developer.ibm.com/tech/sample_code_handler.pl?action=display&object=/tech/sample_code/mq/mqreq.cpp) |
|
Back to top |
|
 |
pchan |
Posted: Thu Feb 21, 2002 8:27 am Post subject: |
|
|
Newbie
Joined: 20 Feb 2002 Posts: 3
|
spoimala,
I am encountering the same issue with C++. Could you post and describe how you've added the method to reset the MQMD.MsgId? I appreciate any help. Thanks.
|
|
Back to top |
|
 |
spoimala |
Posted: Fri Feb 22, 2002 12:27 am Post subject: |
|
|
Novice
Joined: 05 Feb 2002 Posts: 10
|
As I told in my previous post, you can just put
ImqMessage msgRequest;
// clip---clap---
msgRequest.setMessageId();
msgRequest.setCorrelationId(); |
|
Back to top |
|
 |
|