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 » IBM MQ API Support » perl Cannot get message by msgId

Post new topic  Reply to topic
 perl Cannot get message by msgId « View previous topic :: View next topic » 
Author Message
jyx
PostPosted: Thu Jul 15, 2010 7:24 am    Post subject: perl Cannot get message by msgId Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Thu Jul 15, 2010 7:44 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
jyx
PostPosted: Thu Jul 15, 2010 7:51 am    Post subject: Reply with quote

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
View user's profile Send private message
jyx
PostPosted: Thu Jul 15, 2010 10:57 am    Post subject: Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Thu Jul 15, 2010 11:15 am    Post subject: Reply with quote

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
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 » IBM MQ API Support » perl Cannot get message by msgId
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.