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 » General Discussion » MQMessage Length

Post new topic  Reply to topic
 MQMessage Length « View previous topic :: View next topic » 
Author Message
darrylcook
PostPosted: Fri Sep 26, 2008 2:07 am    Post subject: MQMessage Length Reply with quote

Newbie

Joined: 19 Dec 2006
Posts: 6

Hi all,

We run a client server application using MQ as the transport mechanism between the client and server.

We have a single server program that reads the messages off the Q. In this program the logic is as follows:

Browse the first message on Q (to get message length) options are max msg length=0 (i.e no message data is physically retrieved).
Perform a GETMAIn to get buffer storage
MQGET message-under-cursor into buffer

This is done so that the correct amount of storage is allocated for reading the message.

On closer inspection of the calls the browse returns a data length of say 400 bytes, so I allocate the appropriate storage and in the MQGET (of the same message) after the call the the data length is set to 200. I think this is because on the browse as no data is retrieved, no conversion takes place, but on the GET as data is retrieved a conversion takes place.

But...

When I change the browse to actually retrieve the data I then get a message length of 200 bytes returned by the browse, but when I issue the subsequent GET (msg under cursor), the message is returned to the program but the message data length is set to 400.

Can anyone explain whats going on?

I have options set on the browse as
MQGMO-ACCEPT-TRUNCATED-MSG
MQGMO-BROWSE-FIRST
MQGMO-LOCK
MQGMO-WAIT
MQGMO-CONVERT

and on the MQGET
MQGMO-ACCEPT-TRUNCATED-MSG
MQGMO-CONVERT
MQGMO-SYNCPOINT
MQGMO-MSG-UNDER-CURSOR
Back to top
View user's profile Send private message
bruce2359
PostPosted: Fri Sep 26, 2008 6:29 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

This design (brose first, establish the required buffer, then get destructively) has been discussed here at length. The browse call is totally unnecessary. You are doing two calls when one will work perfectly.

Set your buffer to the maximum message length your application expects, then just do the destructive get.
_________________
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
View user's profile Send private message
darrylcook
PostPosted: Fri Sep 26, 2008 6:37 am    Post subject: Reply with quote

Newbie

Joined: 19 Dec 2006
Posts: 6

Um, all very well if you are not restricted on what resources you can have, but this app sits in CICS and there will be many instances of the transaction running at any one time, so just allocating the max storage you MAY need is not sufficient here.

The real question is why do the two gets, one browse, one get return different data lengths.
Back to top
View user's profile Send private message
PeterPotkay
PostPosted: Fri Sep 26, 2008 6:48 am    Post subject: Re: MQMessage Length Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

darrylcook wrote:
Can anyone explain whats going on?

You're on the right track.

Queues that contain messages of different lengths
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
bruce2359
PostPosted: Fri Sep 26, 2008 7:03 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

Quote:
...but this app sits in CICS and there will be many instances of the transaction running at any one time

You are writing an application with the dual intents of satisfying some business requirement ,AND performance tuning for the existing hardware/software environment.

I expected you to say you are doing this on a Windows or UNIX box. CICS, and MVS (z/OS), have the resources to manage hundreds or thousands of concurrent applications.

On any platform, your two API calls where one will do, doubles the requirement for processor cycles in order to reduce the demand for virtual storage - to perhaps reduce paging rates? Is it worth the trade-off?

What real problem are you addressing? Is there a problem?
_________________
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
View user's profile Send private message
bower5932
PostPosted: Fri Sep 26, 2008 7:55 am    Post subject: Reply with quote

Jedi Knight

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

I'd certainly suggest going with a buffer size that would handle most of your requests. 200 bytes vs. 400 bytes doesn't seem worth the trouble (overhead) of going back a second time. 200 bytes vs. 2 million bytes might.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
dkeister
PostPosted: Fri Sep 26, 2008 8:15 am    Post subject: Reply with quote

Disciple

Joined: 25 Mar 2002
Posts: 184
Location: Purchase, New York

Actually, you do not have to browse.

Simply do the get with buffer set to value (e.g. 200 characters)

If the message is too large, you will get an error returned with MQRC 2080 (MQRC_TRUNCATED_MSG_FAILED).

And the data length parameter from the MQGET will contain the length of the message that you were attempting to get. Then use that value to set your buffer length and reissue an MQGET. You can then work with that message.

You can also remember that length and use it for subsequent MQGETs or reset it to some predetermined value, or just (joke) set some random value... As was pointed out to me in one of the other posts... memory is now cheap. But the extra logic is minimal and you would probably want the default message length to be able to handle most messages on the first try...
_________________
Dean Keister
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General Discussion » MQMessage Length
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.