Author |
Message
|
pezi |
Posted: Tue Apr 15, 2008 3:17 am Post subject: Getting the message size without retrieving the message |
|
|
Novice
Joined: 08 Feb 2008 Posts: 15 Location: Vienna/Austria
|
Hi,
Is there a possibility to get the actual message size for an MQ-message without retrieving it?
I'd like to avoid that always the max. message length defined in the queue is allocated.
When I am using MO71 I see the message size already in the table listing the messages and I think that it was not loading all messages to get this information so there must be an API function doing this.
Regards
Peter |
|
Back to top |
|
|
Gaya3 |
Posted: Tue Apr 15, 2008 3:33 am Post subject: |
|
|
Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
you can get those through MQMD Properties.
Regards
Gayathri _________________ Regards
Gayathri
-----------------------------------------------
Do Something Before you Die |
|
Back to top |
|
|
jefflowrey |
Posted: Tue Apr 15, 2008 3:33 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Sure. You can MQGMO_BROWSE+MQGMO_ACCEPT_TRUNCATED_MSG(or whatever it is...) with a buffer size of 1.
This will give you the MQMD with the actual message size. Then you can allocate buffer and GET_MSG_UNDER_CURSOR _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
|
mvic |
Posted: Tue Apr 15, 2008 8:14 am Post subject: |
|
|
Jedi
Joined: 09 Mar 2004 Posts: 2080
|
jefflowrey wrote: |
Sure. You can MQGMO_BROWSE+MQGMO_ACCEPT_TRUNCATED_MSG(or whatever it is...) with a buffer size of 1.
This will give you the MQMD with the actual message size. Then you can allocate buffer and GET_MSG_UNDER_CURSOR |
With browse-get the MQGMO_ACCEPT_TRUNCATED_MSG is a moot point in this context. With non-browse get (... yes I know this is not what you said jeff) don't use MQGMO_ACCEPT_TRUNCATED_MSG in this context as this will accept the message truncated to fit in your 1-byte buffer.
Two solutions to this: (a) use browse then non-browse get (b) use get with buffer size of 0, without MQGMO_ACCEPT_TRUNCATED_MSG, then a non-browse get with the right buffer length.
In either case you can still miss the message if another getter is active on the same queue. If you are the only getter on the queue then you're OK.
There are better ways of doing this if performance matters to you - eg. pre-allocating a large enough buffer for all of the messages you ever expect to see. Uses more memory, but goes faster.
Last edited by mvic on Tue Apr 15, 2008 10:32 am; edited 1 time in total |
|
Back to top |
|
|
EddieA |
Posted: Tue Apr 15, 2008 9:05 am Post subject: |
|
|
Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Gaya3 wrote: |
you can get those through MQMD Properties. |
The message length isn't part of any header.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
|
bruce2359 |
Posted: Tue Apr 15, 2008 9:58 am Post subject: |
|
|
Poobah
Joined: 05 Jan 2008 Posts: 9442 Location: US: west coast, almost. Otherwise, enroute.
|
Quote: |
The message length isn't part of any header |
It's returned as DataLength (MQLONG). See MQGET in the APR manual. _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
|
|