diff options
Diffstat (limited to 'cpp/bindings/qpid/examples/perl/hello_world.pl')
-rwxr-xr-x[-rw-r--r--] | cpp/bindings/qpid/examples/perl/hello_world.pl | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/cpp/bindings/qpid/examples/perl/hello_world.pl b/cpp/bindings/qpid/examples/perl/hello_world.pl index a96b98a002..6ec7d52f1f 100644..100755 --- a/cpp/bindings/qpid/examples/perl/hello_world.pl +++ b/cpp/bindings/qpid/examples/perl/hello_world.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 @@ -21,35 +21,35 @@ use strict; use warnings; use Data::Dumper; -use cqpid_perl; +use qpid; my $broker = ( @ARGV > 0 ) ? $ARGV[0] : "localhost:5672"; my $address = ( @ARGV > 1 ) ? $ARGV[0] : "amq.topic"; my $connectionOptions = ( @ARGV > 2 ) ? $ARGV[1] : ""; -my $connection = new cqpid_perl::Connection($broker, $connectionOptions); +# create a connection +my $connection = new qpid::messaging::Connection( $broker, $connectionOptions ); eval { + # open the connection and create a session, and both a sender a receive $connection->open(); - my $session = $connection->createSession(); - my $receiver = $session->createReceiver($address); - my $sender = $session->createSender($address); + my $session = $connection->create_session(); - $sender->send(new cqpid_perl::Message("Hello world!")); + my $receiver = $session->create_receiver($address); + my $sender = $session->create_sender($address); - #my $duration = new cqpid_perl::Duration(1000); - #print ">>>" . $duration->getMilliseconds() . "\n"; + # send a simple message + $sender->send( new qpid::messaging::Message("Hello world!") ); - my $message = $receiver->fetch($cqpid_perl::Duration::SECOND); + # receive the message, fetching it directly from the broker + my $message = $receiver->fetch(qpid::messaging::Duration::SECOND); - #$message->setDurable(1); - #print "Durable: " . $message->getDurable() . "\n"; - #print Dumper($message->getProperties()); - - print $message->getContent() . "\n"; + # output the message content, then acknowledge it + print $message->get_content() . "\n"; $session->acknowledge(); + # close the connection $connection->close(); }; |