Greetings,

Requirement goes like this. I have perl script reading from a MQ
Series queue. This queue has messages in form of XML.For exmpale
1 message is like  -
<CLIENT_INFO>
        <LOCATION>
                New York
        </LOCATION>
        <FIELD>
        FINANCE GROUP
        </FIELD>
        <NO_OF_WORKERS>
        123
        </NO_OF_WORKERS>
<CLIENT_INFO>


My perl script reads messgaes from this queue, and drops them to
another queue after creating a backup in a text file. My requirement
is I have check the value of a particular tag for example, value of
<FIELD>, if that is  say "FINANCE GROUP", I have to change it to
"FINANCIAL SYSTEMS" and then drop to the other queue. I tried below,
but for some reason it did not work. COuld you please help.

Sample of my script -


# Connect to qmgr
$qmgr = MQSeries::QueueManager->new ( QueueManager => $hOpts{m},
AutoConnect => 0)
        or die "Unable to instantiate MQSeries::QueueManager object
\n";

$qmgr->Connect() or die("Unable to connect to queue manager\n" .
"CompCode => " . $qmgr->CompCode() . "\n" .  "Reason => " .
 $qmgr->Reason() .  " (", MQReasonToText($qmgr->Reason()) . ")\n");

# open input and output queues
my $qIn =MQSeries::Queue->new(QueueManager => $qmgr, Queue =>
$hOpts{i}, Options=>MQSeries::MQOO_INPUT_SHARED )
         or die "Unable to open queue $hOpts{i}" ;

my $qOut=MQSeries::Queue->new ( QueueManager => $qmgr, Queue =>
$hOpts{o}, Options=>MQSeries::MQOO_OUTPUT | MQSeries::MQPMO_S
ET_ALL_CONTEXT )
         or die "Unable to open queue $hOpts{o}" ;

until( $time_to_die )
{
        my $message = MQSeries::Message-
>new(MsgDesc=>{Persistence=>1});

        # Get message from queue
        $result = $qIn->Get( Message => $message, Sync=>1,
Wait=>-1 );
my $msgDescRef = $message->MsgDesc;
my $data = $message->Data;
my $field_name = GetXMLValue($data, "FIELD");
if ($field_name eq 'FINANCE GROUP')
{

$field_name = 'FINANCIAL SYSTEMS';

$msgDescRef->{"FIELD"} = $field_name ;
}
        for(1..$num_retries) {
                $result = $qOut->Put( Message => $message, Sync => 1,
                                PutMsgOpts
=>{ Options=>MQSeries::MQPMO_SET_ALL_CONTEXT ||
 
MQSeries::MQPMO_FAIL_IF_QUIESCING});
                if ($result > 0) { last; }

                sleep $time_to_wait;
        }



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to