Author |
Message
|
colohal |
Posted: Wed Nov 16, 2005 10:23 am Post subject: Open a Queue for Browse and Destructive Get |
|
|
Newbie
Joined: 16 Nov 2005 Posts: 1
|
New to MQ, we need to first browse a message to establish the length, then allocate storage, then get the message off the queue. Do we need to open the queue twice using MQOO-BROWSE then MQOO-INPUT-EXCLUSIVE for example, or is there a way to only open once and perform both MQGET calls? Any ideas out there? |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Nov 16, 2005 10:30 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
The typical way this is handled is to specific an initial buffer of size 1, run a destructive GET - which will throw an error but return the proper length, and then allocate storage and redo the get.
The other option is to always allocate the largest possible buffer, and then reblock after the get is successful. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
EddieA |
Posted: Wed Nov 16, 2005 10:42 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
The typical way this is handled is to specific an initial buffer of size 1 |
Well, that's a way. It would depend on where you were going to get the storage from, and how random in size the messages are. If you are going to have to make requests to CICS, then I'd go for the approach of allocating a buffer that will accomodate all but the "exceptional" size messages, and for those grab the additional storage and re-GET.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Nov 16, 2005 11:24 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I knew I should have said "But I'm not a mainframe programmer." _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
wschutz |
Posted: Wed Nov 16, 2005 11:36 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
Jeff... why not an inital buffer size of 0? Do you get many 1 byte messages????  _________________ -wayne |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Nov 16, 2005 11:48 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
wschutz wrote: |
Jeff... why not an inital buffer size of 0? Do you get many 1 byte messages????  |
Off by one error...  _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
zpat |
Posted: Thu Nov 17, 2005 12:20 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
You could browse with ACCEPTED_TRUNCATED_MESSAGE.
If you repeat an unconditionalMQGET then you might get a entirely different message if any other program was also processing the queue at the same time.
Getting that same message by MSGID is one way to ensure that you get the same message (unless another program has already removed it in which case you just browse the next). |
|
Back to top |
|
 |
|