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 IBM MQ Support » message Get problem

Post new topic  Reply to topic
 message Get problem « View previous topic :: View next topic » 
Author Message
Woo-Shoo, Jeong
PostPosted: Tue Jul 18, 2006 4:47 pm    Post subject: message Get problem Reply with quote

Newbie

Joined: 18 Nov 2005
Posts: 5

Hello!

I have a Queue. There are many messages in the Queue.

I want to get message from that Queue. But I don't know length of message.

To get message using Sample C Source(mqget), I must know length of message. But I don'know.

Prior to run Get sample code, Is there any method to know length of message.
Back to top
View user's profile Send private message MSN Messenger
Vitor
PostPosted: Tue Jul 18, 2006 11:23 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Three methods I can think of:

1) Browse the message; this will set the message length parameter in the MQGET call. Set the message buffer to this length and do the destructive get

or my preferred option:

2) Set the buffer to the size of the largest message you think is likely and put in error handling to trap the truncated message condition. Most of the gets will suceed because the buffer is large enough. Those that fail, reset the buffer using the length parameter as above

or finally

3) Set the buffer to the max message length of the queue!!

(Clearly 3 may be unsuitable if you're short on memory and/or have a very large max length. It's also vunerable to some administrator changing the max length at some future point, but it's head and shoulders the easiest to implement )

Have fun now
_________________
Honesty is the best policy.
Insanity is the best defence.


Last edited by Vitor on Wed Jul 19, 2006 12:43 am; edited 1 time in total
Back to top
View user's profile Send private message
Nigelg
PostPosted: Wed Jul 19, 2006 12:35 am    Post subject: Reply with quote

Grand Master

Joined: 02 Aug 2004
Posts: 1046

All of Vitor's solutions may have problems.

1. |You should do browse with LOCK, and then MSG_UNDER_CIRSOR, to make sure that the destructive get is returned the same msg as the browse.
If you are doing CONVERT, you should bear in mind that the msg may expand on conversion if converting to UTF-8 or any other MBCS code page, and adjust the buffer size accordingly.

2. Rather wasteful of memory, and suffers from the same problem as the browse in that the get after the truncated msg may not get the same msg. There is no equivalent of MSG_UNDER_CURSOR for a second destructive get, but you could read the msg the second time by MsgId, if they are unique on your system.

3. Definitely wasteful on memory!
_________________
MQSeries.net helps those who help themselves..
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jul 19, 2006 12:50 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Nigelg

I do take your points, especially the importance of browse with lock which I omitted from my original post!

Option 2 is only wasteful of memory if you have a message significantly larger than the average which infrequently occurs. It's a matter of design and therefore allows no "right" answer; I prefer to have message types grouped one to a queue and hence a very even distribution of lengths.

Option 3 - I don't think "wasteful" quite covers it! Dead simple to code though....
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jul 19, 2006 1:47 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Memory is cheaper than downtime or dropped messages.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
PeterPotkay
PostPosted: Wed Jul 19, 2006 5:59 pm    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

Nigelg wrote:
All of Vitor's solutions may have problems.

1. |You should do browse with LOCK, and then MSG_UNDER_CIRSOR, to make sure that the destructive get is returned the same msg as the browse.
If you are doing CONVERT, you should bear in mind that the msg may expand on conversion if converting to UTF-8 or any other MBCS code page, and adjust the buffer size accordingly.

Or open the queue exclusivly, and skip the browsing altogether.
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
belchman
PostPosted: Mon Jul 24, 2006 9:39 am    Post subject: Reply with quote

Partisan

Joined: 31 Mar 2006
Posts: 386
Location: Ohio, USA

Or download and use supportpac MA01
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » message Get problem
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.