summaryrefslogtreecommitdiff
path: root/cpp/bindings/qpid/examples/perl/client.pl
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2013-02-28 16:14:30 +0000
committerKim van der Riet <kpvdr@apache.org>2013-02-28 16:14:30 +0000
commit9c73ef7a5ac10acd6a50d5d52bd721fc2faa5919 (patch)
tree2a890e1df09e5b896a9b4168a7b22648f559a1f2 /cpp/bindings/qpid/examples/perl/client.pl
parent172d9b2a16cfb817bbe632d050acba7e31401cd2 (diff)
downloadqpid-python-asyncstore.tar.gz
Update from trunk r1375509 through r1450773asyncstore
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1451244 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/bindings/qpid/examples/perl/client.pl')
-rwxr-xr-x[-rw-r--r--]cpp/bindings/qpid/examples/perl/client.pl72
1 files changed, 42 insertions, 30 deletions
diff --git a/cpp/bindings/qpid/examples/perl/client.pl b/cpp/bindings/qpid/examples/perl/client.pl
index 19d9d3f14f..586beb787e 100644..100755
--- a/cpp/bindings/qpid/examples/perl/client.pl
+++ b/cpp/bindings/qpid/examples/perl/client.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -20,47 +20,59 @@
use strict;
use warnings;
-use cqpid_perl;
+use qpid;
-my $url = ( @ARGV == 1 ) ? $ARGV[0] : "amqp:tcp:127.0.0.1:5672";
-my $connectionOptions = ( @ARGV > 1 ) ? $ARGV[1] : "";
+my $url = ( @ARGV == 1 ) ? $ARGV[0] : "amqp:tcp:127.0.0.1:5672";
+my $connectionOptions = ( @ARGV > 1 ) ? $ARGV[1] : "";
-
-my $connection = new cqpid_perl::Connection($url, $connectionOptions);
+# creates a new connection instance
+my $connection = new qpid::messaging::Connection( $url, $connectionOptions );
eval {
-$connection->open();
-my $session = $connection->createSession();
+ # open the connection and create a session for interacting with it
+ $connection->open();
-my $sender = $session->createSender("service_queue");
+ my $session = $connection->create_session();
+ my $sender = $session->create_sender("service_queue");
-#create temp queue & receiver...
-my $responseQueue = new cqpid_perl::Address("#response-queue; {create:always, delete:always}");
-my $receiver = $session->createReceiver($responseQueue);
+ # create an address and receiver for incoming messages
+ # the queue will be created always, and will be deleted
+ # when the receive disconnects
+ my $responseQueue = new qpid::messaging::Address(
+ "#response-queue; {create:always, delete:always}");
+ my $receiver = $session->create_receiver($responseQueue);
-#Now send some messages...
+ # Now send some messages...
-my @s = (
- "Twas brillig, and the slithy toves",
- "Did gire and gymble in the wabe.",
- "All mimsy were the borogroves,",
- "And the mome raths outgrabe."
- );
+ my @s = (
+ "Twas brillig, and the slithy toves",
+ "Did gire and gymble in the wabe.",
+ "All mimsy were the borogroves,",
+ "And the mome raths outgrabe."
+ );
-my $request = new cqpid_perl::Message();
-$request->setReplyTo($responseQueue);
-for (my $i=0; $i<4; $i++) {
- $request->setContent($s[$i]);
- $sender->send($request);
- my $response = $receiver->fetch();
- print $request->getContent() . " -> " . $response->getContent() . "\n";
-}
+ # create the message object, and set a reply-to address
+ # so that the server knows where to send responses
+ # the message object will be reused to send each line
+ my $request = new qpid::messaging::Message();
+ $request->set_reply_to($responseQueue);
+ for ( my $i = 0 ; $i < 4 ; $i++ ) {
+ $request->set_content( $s[$i] );
+ $sender->send($request);
+
+ # wait for the response to the last line sent
+ # the message will be taken directly from the
+ # broker's queue rather than waiting for it
+ # to be queued locally
+ my $response = $receiver->fetch();
+ print $request->get_content() . " -> "
+ . $response->get_content() . "\n";
+ }
-$connection->close();
+ # close the connection
+ $connection->close();
};
if ($@) {
die $@;
}
-
-