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 MQSeries module - message disappears at the time of Get

Post new topic  Reply to topic
 Perl MQSeries module - message disappears at the time of Get « View previous topic :: View next topic » 
Author Message
any2xml
PostPosted: Thu May 20, 2004 3:48 pm    Post subject: Perl MQSeries module - message disappears at the time of Get Reply with quote

Apprentice

Joined: 18 May 2004
Posts: 42

I use MQSeries Perl module to 'put' messages but when I tried to 'get', they seem to disappear. See the "$qobj->Get" below? Just before executing it, I see a value 2 in CURDEPTH for the queue (from another ssh session running 'runmqsc'). But after the Get, it is zero and the Get comes up empty!

Is it the way I am 'put'ting (persistence etc) or the Get destructively reads before actually getting the message? What am I doing wrong? Thanks

Code:

sub receive_from_customs {
my $param = shift;

# Read the next message from the queue and return to requester
# no input variable required.
#
my $mode = 'input';
  my $qobj =  MQSeries::Queue->new
    (
     QueueManager         => $param->{qmgr},
     Queue                => $param->{queue},
     Mode                 => $mode,
    ) || return "Unable to open ".$param->{queue}." to READ\n";

    my $msgobj = MQSeries::Message->new() ||
          return "Unable to create message object for receive";

    $qobj->Get
      (
       Message  => $msgobj,
       Wait     => ($param->{poll_rate} || 1),
      ) || return "Error occured while waiting to READ queue ".$param->{queue}.
       " from qmgr = ".$param->{qmgr}."\n";
#  -- what return codes are acceptable?

    delete $param->{message};

    if ( my $x = $qobj->Reason()) {
       unless ($x == MQRC_NO_MSG_AVAILABLE ) {
        return  "Problem (mqrc = '$x') reading from queue ".$param->{queue}.
                " for qmgr ".$param->{qmgr}."\n";
       }
    } else {

      $param->{message} = $msgobj->Data();
    }
    return;  # required to return false value (success)
}

_________________
A Perl Hacker
http://www.goreliance.com
http://www.any2xml.com
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu May 20, 2004 4:14 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Most likely, your message is expiring before you can get it.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
clindsey
PostPosted: Thu May 20, 2004 4:51 pm    Post subject: Reply with quote

Knight

Joined: 12 Jul 2002
Posts: 586
Location: Dallas, Tx

Another possibility is the 2 messages were put with sync option but not committed. If these were put on the queue by your perl app, check the PutMsgOptions to see if you set MQPMO_SYNCPOINT or if you passed Sync as an option in the Put. In either of these cases, you need to call the queue manager objects 'Commit' method.

This is not related to the problem, but you might consider constructing your input queue object at startup and save the handle. Then it doesn't have to do a queue open each time receive_from_customs is called. It will get destructed when the app ends.

Charlie
Back to top
View user's profile Send private message
any2xml
PostPosted: Sat May 22, 2004 10:20 pm    Post subject: Messages dont get stored Reply with quote

Apprentice

Joined: 18 May 2004
Posts: 42

Thanks for the suggestions. I remember at one time during the testing I turned on AutoCommit and the messages persisted.

But now I pass 'Sync' as an option in put, and I also call Commit. Yet I dont see the messages going into the queue. There is some other problem. It was mentioned that the message is 'expiring' before I get to it. Does it mean that the time to commit has expired? I get no errors during 'Put" or "Commit".

BTW, I created a module for this interface taking your suggestion on creating the handle only once. Thanks for that.
_________________
A Perl Hacker
http://www.goreliance.com
http://www.any2xml.com
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Sun May 23, 2004 5:14 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

There's an Expiry property of the message.
Quote:
Expiry (MQLONG)
Message lifetime.

This is a period of time expressed in tenths of a second, set by the application that puts the message. The message becomes eligible to be discarded if it has not been removed from the destination queue before this period of time elapses.


If you're setting this too small, then the message will never be available to be gotten - it will show up in the queue depth but the instant someone tries to get any message from that queue it will be removed.

Please post the code that is being used to PUT your messages, rather than the code that is being used to GET them.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
any2xml
PostPosted: Sun May 23, 2004 10:59 am    Post subject: Good catch! It was the Expiry Reply with quote

Apprentice

Joined: 18 May 2004
Posts: 42

It was the Expiry. Thanks. Setting it high and even dropping it helped.


Quote:
my $msgobj = MQSeries::Message->new
(
MsgDesc =>
{
Format => MQFMT_STRING,
# Expiry => ($param->{expiry} || 5000000),
},
Data => undef,
) || return "Unable to create message object for SEND\n";

$msgobj->{Data} = $param->{message};

unless ($self->{qobj}->Put( Message => $msgobj,Sync => 1 )) {
return "Unable to SEND message \n". $param->{message}. "\n to output queue ".$self->{qobj}->{Queue}.
"for qmgr ".$self->{qobj}->QueueManager()->{QueueManager}."\n Did you set the mode correctly?\n";
}
[/code]
_________________
A Perl Hacker
http://www.goreliance.com
http://www.any2xml.com
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 MQSeries module - message disappears at the time of Get
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.