Why not adopt me?
This distribution is up for adoption!
If you're interested then please contact the PAUSE module admins via
email.
NAME
POEx::ZMQ3::Publisher - A PUB-type ZeroMQ socket
SYNOPSIS
use POE;
my $zpub = POEx::ZMQ3::Publisher->new();
POE::Session->create(
inline_states => {
_start => sub {
## Bind our Publisher to some endpoints:
$zsub->start(
'tcp://127.0.0.1:5665',
'tcp://127.0.0.1:1234',
);
## Our session wants all emitted events:
$_[KERNEL]->post( $zsub->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 {
$zsub->publish(
'This is data \o/'
);
$_[KERNEL]->delay( push_messages => 1 );
},
}
);
$poe_kernel->run;
DESCRIPTION
A lightweight ZeroMQ publisher-type socket using POEx::ZMQ3::Role::Endpoints and MooX::Role::POE::Emitter (see their respective documentation for relevant methods).
Methods
start
$zsub->start( @publish_on );
Start the Publisher and bind some endpoint(s).
stop
$zsub->stop;
Stop the Publisher, closing out the socket and stopping the event emitter.
publish
$zsub->publish( @data );
Publish some item(s) to the ZeroMQ socket.
This base class does no special serialization on its own.
publish_multipart
$zsub->publish_multipart( $envelope, @data );
Publish a multipart message.
See the ZeroMQ documentation for more on multipart messages.
Events
zeromq_publishing_on
Emitted when we are initialized; $_[ARG0] is the endpoint we are publishing on.
SEE ALSO
AUTHOR
Jon Portnoy <avenj@cobaltirc.org>