Net::Stomp::ProducerHelper object to send messages via Net::Stomp | |
Download |
Net::Stomp::Producer Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Gianni Ceccarelli
- Publisher web site:
- http://search.cpan.org/~dakkar/
Net::Stomp::Producer Tags
Net::Stomp::Producer Description
Net::Stomp::Producer is a Perl class that sends messages via a STOMP connection (see Net::Stomp::MooseHelpers::CanConnect). It provides facilities for serialisation and validation. You can have an instance of this class as a singleton / global in your process, and use it to send all your messages: this is recommended, as it will prevent flooding the broker with many connections (each instance would connect independently, and if you create many instances per second, the broker or your process may run out of file descriptiors and stop working).SYNOPSIS my $ser = JSON::XS->new->utf8; my $p = Net::Stomp::Producer->new({ servers => , serializer => sub { $ser->encode($_) }, default_headers => { 'content-type' => 'json' }, }); $p->send('/queue/somewhere', { type => 'my_message' }, { a => });Also: package My::Message::Transformer { use Moose; sub transform { my ($self,@elems) = @_; return { destination => '/queue/somewhere', type => 'my_message', }, { a => \@elems }; } } $p->transform_and_send('My::Message::Transformer', 'data','structure');Or even: my $t = My::Message::Transformer->new(); $p->transform_and_send($t, 'data','structure');They all send the same message.Product's homepage
Net::Stomp::Producer Related Software