POEx::ZMQ3::Publisher - A PUB-type ZeroMQ socket
use POE; my $zpub = POEx::ZMQ3::Publisher->new(); POE::Session->create( inline_states => { _start => sub { ## Bind our Publisher to some endpoints: $zpub->start( 'tcp://127.0.0.1:5665', 'tcp://127.0.0.1:1234', ); ## Our session wants all emitted events: $_[KERNEL]->post( $zpub->session_id, 'subscribe', 'all' ); ## Push messages on a timer loop forever: $_[KERNEL]->delay( push_messages => 1 ); }, zeromq_publishing_on => sub { my $endpoint = $_[ARG0]; print "Publishing on $endpoint\n"; }, push_messages => sub { $zpub->publish( 'This is data \o/' ); $_[KERNEL]->delay( push_messages => 1 ); }, } ); $poe_kernel->run;
A lightweight ZeroMQ publisher-type socket using POEx::ZMQ3::Role::Emitter.
$zpub->start( @publish_on );
Start the Publisher and bind some endpoint(s).
$zpub->stop;
Stop the Publisher, closing out the socket and stopping the event emitter.
$zpub->publish( @data );
Publish some item(s) to the ZeroMQ socket as individual single-part messages.
This base class does no special serialization on its own.
$zpub->publish_multipart( @data );
Publish multi-part data. For PUB-type sockets, this is frequently used to create message envelopes a SUB-type socket can subscribe to:
$zpub->publish_multipart( $prefix, $data );
Emitted when we are initialized; $_[ARG0] is the endpoint we are publishing on.
POEx::ZMQ3
POEx::ZMQ3::Subscriber
ZMQ::LibZMQ3
http://www.zeromq.org
Jon Portnoy <avenj@cobaltirc.org>
To install POEx::ZMQ3, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POEx::ZMQ3
CPAN shell
perl -MCPAN -e shell install POEx::ZMQ3
For more information on module installation, please visit the detailed CPAN module installation guide.