rabbitmq-tutorials/perl/new_task.pl
Colin Blower fc06c863ac Improve perl tutorial files.
Fixed a few spelling errors. Removed unnecessary timeout argument from
some connections. Removed on_return callback from send.pl. Modified
rpc_client to allow parameter passing. Added autoflush, $|++, to allow
for automated testing.
2012-07-11 09:18:12 -07:00

37 lines
531 B
Perl

#!/usr/bin/perl
use strict;
use warnings;
$|++;
use Net::RabbitFoot;
my $conn = Net::RabbitFoot->new()->load_xml_spec()->connect(
host => 'localhost',
port => 5672,
user => 'guest',
pass => 'guest',
vhost => '/',
);
my $chan = $conn->open_channel();
$chan->declare_queue(
queue => 'task_queue',
durable => 1,
);
my $msg = join(' ', @ARGV) || "Hello World!";
$chan->publish(
exchange => '',
routing_key => 'task_queue',
body => $msg,
);
print " [x] Sent '$msg'\n";
$conn->close();