Author |
Message
|
danhoffman |
Posted: Wed May 31, 2006 12:26 pm Post subject: Confused on how to get MQMD fields from ImqMessage |
|
|
Apprentice
Joined: 03 Nov 2005 Posts: 25
|
Hi,
I'm using ImqMessage in the C++ api to get messages from a queue. I see classes like ImqMessageTracker but I'm not sure how they interact with ImqMessage. For example, I don't see any functions that will return an ImqMessage object, nor any way to pass a pointer or reference to one on the ImqQueue.get call. How can I get the correlid, msgid, etc. once I have an ImqMessage object? (Note, I don't need to query by msgid or correlid, I just want to know it for every message that I get).
Thanks. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 31, 2006 12:50 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
danhoffman |
Posted: Wed May 31, 2006 12:55 pm Post subject: I have those links |
|
|
Apprentice
Joined: 03 Nov 2005 Posts: 25
|
jeff,
I have those links. Still confused. I do not see any functions inside ImqMessage that get me the ImqMessageTracker. The MQMD. Do you have any sample code that shows instantiating the ImqMessageTracker, doing a get off of the queue and accessing the MQMD?
Dan |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 31, 2006 1:06 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
The second link I posted says *to me* that if I have an ImqMessage object called "myMsg", then if I want to get the MQMD, I can access "myMsg.MQMD" and then access the individual fields under that as if it were a normal MQMD C structure.
And the first link says that *to me* (my C++ is rusty), that if I want to get the PutTime as an ImqString I can call "myMsg.putTime()", and have an ImqString* returned to me.
I don't know why one would use an ImqMessageTracker, myself. It seems to only have a subset of fields of the MQMD. Maybe you can use it to specify match options without having to build a full ImqMessage object. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
danhoffman |
Posted: Wed May 31, 2006 2:58 pm Post subject: |
|
|
Apprentice
Joined: 03 Nov 2005 Posts: 25
|
jefflowrey wrote: |
The second link I posted says *to me* that if I have an ImqMessage object called "myMsg", then if I want to get the MQMD, I can access "myMsg.MQMD" and then access the individual fields under that as if it were a normal MQMD C structure. |
That's the thing - the MQMD has 'protected' access which means I would have to descend my own class from ImqMessage just to try and get it. (It just doesn't seem like the 'right' thing to have to do ). |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 31, 2006 2:59 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Right, but all the fields of the MQMD should be available through the public methods listed in the first link. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
danhoffman |
Posted: Wed May 31, 2006 4:25 pm Post subject: |
|
|
Apprentice
Joined: 03 Nov 2005 Posts: 25
|
jefflowrey wrote: |
Right, but all the fields of the MQMD should be available through the public methods listed in the first link. |
They don't - at least not for msgid and correlation id, which are the ones I'm primarily concerned with. (That's why I started this thread...) |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 31, 2006 4:43 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Probably a bug in the documentation.
The imqsget.cpp sample code shows
Code: |
msg.setMessageId( );
msg.setCorrelationId( ); |
_________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
danhoffman |
Posted: Wed May 31, 2006 4:46 pm Post subject: |
|
|
Apprentice
Joined: 03 Nov 2005 Posts: 25
|
jefflowrey wrote: |
Probably a bug in the documentation.
The imqsget.cpp sample code shows
Code: |
msg.setMessageId( );
msg.setCorrelationId( ); |
|
I don't want to SET it, I want to GET it! |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 31, 2006 4:58 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Yes.
I'm assuming that the analog would be "msg.MessageId();", or perhaps "msg.messageId();" - since that's the naming standard the classes use for all of the other fields.
But I'm not willing to try and throw together a C++ compilation environment to test it. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
danhoffman |
Posted: Wed May 31, 2006 5:02 pm Post subject: |
|
|
Apprentice
Joined: 03 Nov 2005 Posts: 25
|
I've grepped for it in /opt/mqm/inc, and it only exists in the ImqMessageTracker.... feels like we're going in circles, doesn't it?
|/opt/mqm/inc> grep -i messageid *
imqmtr.hpp: void * opvoidMessageId ;
imqmtr.hpp: ImqBinary messageId ( ) const ;
imqmtr.hpp: ImqBoolean setMessageId ( const ImqBinary & );
imqmtr.hpp: void setMessageId ( const unsigned char * = 0 ); |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 31, 2006 6:44 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
What happens when you just try it?
What happens when you, for example, cast an ImqMessage as an ImqMessageTracker object? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
danhoffman |
Posted: Wed May 31, 2006 6:47 pm Post subject: |
|
|
Apprentice
Joined: 03 Nov 2005 Posts: 25
|
Yeah, already tried that. I also tried to descend from ImqMessage to make the MQMD useable, didn't work. Just looks like the C++ api is not complete and that my alternative is java or C. |
|
Back to top |
|
 |
bower5932 |
Posted: Wed May 31, 2006 7:02 pm Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
|
Back to top |
|
 |
danhoffman |
Posted: Wed May 31, 2006 7:07 pm Post subject: |
|
|
Apprentice
Joined: 03 Nov 2005 Posts: 25
|
It turns out that ImqMessage descends from ImqMessageTracker and ImqCache (I found this out only by looking at the .hpp file)
Therefore, all methods from ImqMessageTracker and ImqCache can be called on an ImqMessage object. (So the messageId() function works).
Thanks for your help. |
|
Back to top |
|
 |
|