|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
MQGET not doing unlimited wait |
« View previous topic :: View next topic » |
Author |
Message
|
hank |
Posted: Mon Aug 22, 2005 10:46 am Post subject: MQGET not doing unlimited wait |
|
|
Newbie
Joined: 22 Aug 2005 Posts: 3
|
I have a perl code MQGET script that does not do an unlimited wait, as I require.... The code I am using is below. It works fine, except that it falls through to the next statement if the queue is empty. I want it to wait for the next message. If any one can see what is wrong, I would be greatful.
Thank you
my $GetMsgOpts = {
Options =>
MQGMO_ACCEPT_TRUNCATED_MSG => 64,
MQGMO_WAIT,
MQGMO_NO_SYNCPOINT,
MQGMO_CONVERT,
WaitInterval => MQWI_UNLIMITED,
};
my $MsgDesc = {MQMD_DEFAULT,
Format => MQFMT_STRING};
$buffer = MQGET($Hconn,
$Hobj_snd,
$MsgDesc,
$GetMsgOpts,
$buflen,
$CompCode,
$Reason); |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Aug 22, 2005 10:56 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
MQSeries.pm perldoc wrote: |
MQGET
$Buffer = MQGET($Hconn,$Hobj,$MsgDesc,$GetMsgOpts,$BufferLength,$CompCode,$Reason);
One positional parameter, the $Buffer, is removed from the argument list. This is the return value of this subroutine. The $MsgDesc and $GetMsgOpts values are hash references. The $MsgDesc will be populated with the MQMD structure returned by the MQGET call. This is also an input value, and the $MsgDesc data can be populated, for example, with a specific 'CorrelId'.
$MsgDesc = {
CorrelId => $correlid,
};
The $GetMsgOpts hash reference contains the MQGMO data structure fields, for example:
$GetMsgOpts = {
Options => MQGMO_FAIL_IF_QUIESCING | MQGMO_SYNCPOINT | MQGMO_WAIT,
WaitInterval => MQWI_UNLIMITED,
}; |
This doesn't really match with what you posted. In fact, what you posted for $GetMsgOpts doesn't make any sense to me at all... But maybe I'm confused.
Also, I don't think your $MsgDesc will do anything useful. You can't match on Format, as far as I know.
I have gotten Get with wait to work just fine with the Object Oriented interface, and never bothered with the straight API interface. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
JT |
Posted: Mon Aug 22, 2005 11:04 am Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
What's the Reason Code value ?
If it's not '2033', then you did successfully retrieve a message from the queue. |
|
Back to top |
|
 |
hank |
Posted: Tue Aug 23, 2005 4:25 am Post subject: |
|
|
Newbie
Joined: 22 Aug 2005 Posts: 3
|
I appreciate your inputs.
I checked my input against the code jefflowrey sent me. And I seem to be loading the unlimited wait options correctly, even if they are different.
Regarding using the client version vs the OO interface, I simply inherited this and don't think it is worth rewriting, since everything else works fine.
The reason I keep getting on the MQGET is 2033. As far as I understand it, this says it did not find a message and continues. I thought the "WaitInterval => MQWI_UNLIMITED" was supposed to tell it to wait for a message?? |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Aug 23, 2005 4:35 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I guess what I'm saying is, that if it's returning, then you *aren't* setting WAIT_UNLIMITED or MQGMO_WAIT correctly...
Particularly confusing to me is that you are attempting to ascribe a value to MQGMO_ACCEPT_TRUCATED_MSG. Or at least, treat it as a hash key and associate it with a value.
The entire options field is a single integer in the MQ API. It's possible, but doesn't seem to be documented, that the Perl API wraps some additional logic around the options field above and beyond the hashmap... But I don't trust it, and it seems like it's not working for you.
Change your MQGMO code to
Code: |
my $GetMsgOpts = {
Options =>
MQGMO_ACCEPT_TRUNCATED_MSG|MQGMO_WAIT|MQGMO_NO_SYNCPOINT|MQGMO_CONVERT,
WaitInterval => MQWI_UNLIMITED,
}; |
and see what happens... _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
hank |
Posted: Tue Aug 23, 2005 4:48 am Post subject: |
|
|
Newbie
Joined: 22 Aug 2005 Posts: 3
|
I tried the simpler getoptions from your previous message and that seemed to work. I am not sure if removing the "MQGMO_ACCEPT_TRUNCATED_MSG" will create another problem. It may only have been required for a previous application. I will have to do more testing on that. But at least the wait seems OK now. The format I am using was inherited but I did find google search references to assigning a value to the truncated option (gives it minimun truncated amount to accept). Unless I misunderstand what I am reading, which is possible....
In any case, now I can move forward. Thanks for your help. |
|
Back to top |
|
 |
kman |
Posted: Wed Aug 24, 2005 10:04 pm Post subject: |
|
|
Partisan
Joined: 21 Jan 2003 Posts: 309 Location: Kuala Lumpur, Malaysia
|
If you don't put ACCEPT_TRUNCATED_MSG, you may end up with mqrc 2080 - MQRC_TRUNCATED_MSG_FAILED if the buffer is smaller than the message. If you include the option, the Truncated Msg will be accepted.
Just thought you should know. |
|
Back to top |
|
 |
kevinf2349 |
Posted: Fri Aug 26, 2005 8:16 pm Post subject: |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
I am not a C programmer so please forgive me if this is a stupid question but.....
What does this do?
Quote: |
MQGMO_ACCEPT_TRUNCATED_MSG => 64,
|
Shouldn't it just be
Code: |
MQGMO_ACCEPT_TRUNCATED_MSG,
|
Doesn't adding the => make the value get set incorrectly?
Do you think that the 64 is some sort of length?....because it shouldn't be. You don't specify a length in the GMO.
Just curious.  |
|
Back to top |
|
 |
hopsala |
Posted: Sat Aug 27, 2005 4:31 am Post subject: |
|
|
 Guardian
Joined: 24 Sep 2004 Posts: 960
|
hank wrote: |
assigning a value to the truncated option (gives it minimun truncated amount to accept). |
Just to clarify kevin's point - MQGMO_ACCEPT_TRUNCATED_MSG does not state a minimum amount to accept, it is a boolean option (like all MQGMO) that means "if message too big, then truncate"; the max size is determined by the buffer size ($buflen) you specify in your MQGET.
Btw, you do realize you will lose application data using this option...? |
|
Back to top |
|
 |
jefflowrey |
Posted: Sat Aug 27, 2005 4:56 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
To answer kevin's question, taken literally, what
Code: |
MQGMO_ACCEPT_TRUNCATED_MSG => 64, |
The => in Perl is a form of the comma (a list separator). In fact, the only sematic distinction between "," and "=>" is that the later forces the left hand side to be interpreted as a string. So the original code posted is semantically equivalent to
Code: |
my $GetMsgOpts = {
'Options',
'MQGMO_ACCEPT_TRUNCATED_MSG', 64,
MQGMO_WAIT,
MQGMO_NO_SYNCPOINT,
MQGMO_CONVERT,
'WaitInterval',MQWI_UNLIMITED,
}; |
Which would evalute to a hash having the following key/value pairs.
'Options','MQGMO_ACCEPT_TRUNCATED_MSG'
'64','MQGMO_WAIT',
'MQGMO_NO_SYNCPOINT,'MQGMO_CONVERT
'WaitInterval,'MQWI_UNLIMITED'
This, I think, would end up trying to convert 'MQGMO_ACCEPT_TRUNCATED_MSG' into an integer value. In Perl, strings that aren't numbers are treated as 0 (as in awk). So basically, he was assigning 0 to Options and MQWI_UNLIMITED to WaitInterval and everything else was being ignored.
All of the rest of the discussion around this is interesting, but Hank has probably wandered off, unless he is getting notifications every time someone replies to this thread. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|