summaryrefslogtreecommitdiff
path: root/deps/rabbitmq_stomp/examples/perl/rabbitmq_stomp_rpc_service.pl
blob: 31e79aea4abc09e6cc76e67026499ddf0ddf2c21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/perl -w

use Net::Stomp;

my $stomp = Net::Stomp->new({hostname=>'localhost', port=>'61613'});
$stomp->connect({login=>'guest', passcode=>'guest'});

$stomp->subscribe({'destination'=>'/queue/rabbitmq_stomp_rpc_service', 'ack'=>'client'});
while (1) {
    print "Waiting for request...\n";
    my $frame = $stomp->receive_frame;
    print "Received message, reply_to = " . $frame->headers->{"reply-to"} . "\n";
    print $frame->body . "\n";

    $stomp->send({destination => $frame->headers->{"reply-to"}, bytes_message => 1,
                  body => "Got body: " . $frame->body});
    $stomp->ack({frame=>$frame});
    last if $frame->body eq 'QUIT';
}

$stomp->disconnect;