Script file to retrieve MQ messages from the queue manager

I want to write a script file that will add received MQ messages in the queue manager in the log file. Please, help

+3
source share
1 answer

If you want all the messages received on the channel, you can use LogIP output page BlockIP2 mrmq.dk . An API output, such as SupportPac MA0W , can log all messages posted. The exit API can send cache messages from local applications, as well as from those that arrive through the channels.

If you want a script, you can use a program such as Q (from SupportPac MA01 ) to remove messages from the queue as they arrive and add to the file.

For instance,

#!/usr/bin/ksh

q -IMYQMGR/MY.QUEUE >> logfile.txt

Typically, a script is run and configured to add new messages to the file. The problem is that it destroys messages. If there is a recording application requiring the use of these messages, this is not a great solution. You can view the queue, but there is no guarantee of receiving messages before the recording application receives them, and the viewing will be periodically restarted at the head of the queue so that you can record the same message twice.

Perl MQSeries. API WMQ, - . - , Q . - , API script ( ), Perl MQSeries - . , , , :

while (1) {
    $sync_flag = 0;
    undef $outcome;
    my $request_msg = MQSeries::Message::->new();
    my $status = $request_queue->
      Get('Message'       => $request_msg,
          'GetMsgOpts' =>
          {
           'WaitInterval' => 5000,  # 5 seconds
           'Options'      => (MQSeries::MQGMO_WAIT |
                              MQSeries::MQGMO_SYNCPOINT_IF_PERSISTENT |
                              MQSeries::MQGMO_CONVERT |
                              MQSeries::MQGMO_FAIL_IF_QUIESCING),
          },
         );
    unless ($status) {  # Error
        my $rc = $request_queue->Reason();
        die "Error on 'Get' from queue $qmgr_name/$request_qname:\n" .
          "\tReason: $rc (" . MQReasonToText($rc). ")\n";
    }
    next if ($status < 0);      # No message available

, , - . , , GET , . , .

+1

All Articles