|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
perl Cannot get message by msgId |
« View previous topic :: View next topic » |
Author |
Message
|
jyx |
Posted: Thu Jul 15, 2010 7:24 am Post subject: perl Cannot get message by msgId |
|
|
Newbie
Joined: 14 Jul 2010 Posts: 4
|
After I put a message in a queue, I tried to get the message by its MsgId. However, it seems that I always get the first message instead of the message with MsgId I passed to getMessage(). Did I miss any option here? Thanks!
**********************************
my $msgId = putMessage($msgQueue, $data);
my $replyData = getMessage($msgQueue, $msgId);
sub getMessage
{
my ($queue, $msgId) = @_;
my $msg = MQSeries::Message->new
(
MsgDec =>
{
MsgId => $msgId,
format => MQSeries::MQFMT_STRING
}
) or confess "Unable to instantiate MQSeries::Message object before Get Message\n";
unless ($queue->Get( Message => $msg,
GetMsgOpts => {
MatchOptions => MQSeries::MQMO_MATCH_MSG_ID
}
))
{
confess ("Get Queue failed:\n" .
"\tCompCode => " . $queue->CompCode() . "\n" .
"\tReason => " . $queue->Reason(). "\n" .
"\tReason Text => " . MQReasonToText($queue->Reason()). "\n");
}
return $msg->Data();
} |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jul 15, 2010 7:44 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You're trying to do something funky...
The messageId has no value until the message is sent/put.
Once the message is sent(put), you need to extract it from the message.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
jyx |
Posted: Thu Jul 15, 2010 7:51 am Post subject: |
|
|
Newbie
Joined: 14 Jul 2010 Posts: 4
|
I did put the message with the following before getMessage:
my $msgId = putMessage($msgQueue, $data); |
|
Back to top |
|
 |
jyx |
Posted: Thu Jul 15, 2010 10:57 am Post subject: |
|
|
Newbie
Joined: 14 Jul 2010 Posts: 4
|
I found the problem. there is a typo, and the MQ or Perl interpreter just ignored it without a warning:(
my $msg = MQSeries::Message->new
(
MsgDesc =>
{
MsgId => $msgId,
format => MQSeries::MQFMT_STRING
} |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jul 15, 2010 11:15 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It'd be your perl interpreter that ignored it. #use strict; and -w can be a help... |
|
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
|
|
|
|