Menu Search

send.pl

use strict;
use warnings;
use Getopt::Std;

use qpid_proton;

sub usage {
    exit(0);
}

my $address = "0.0.0.0";

my %options = ();
getopts("ha:", \%options) or usage();
usage if $options{h};

$address = $options{a} if defined $options{a};

my $msg  = new qpid::proton::Message();
my $messenger = new qpid::proton::Messenger();

$messenger->start();

my @messages = @ARGV;
@messages = ("This is a test. " . localtime(time)) unless $messages[0];

foreach (@messages)
{
    $msg->set_address($address);
    $msg->set_content($_);
    $messenger->put($msg);
}

$messenger->send();
$messenger->stop();

die $@ if ($@);

Download this file