The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

POEx::ZMQ3::Publisher

SYNOPSIS

  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;

DESCRIPTION

A lightweight ZeroMQ publisher-type socket using POEx::ZMQ3::Role::Emitter.

Methods

start

  $zpub->start( @publish_on );

Start the Publisher and bind some endpoint(s).

stop

  $zpub->stop;

Stop the Publisher, closing out the socket and stopping the event emitter.

publish

  $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.

publish_multipart

  $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 );

Events

zeromq_publishing_on

Emitted when we are initialized; $_[ARG0] is the endpoint we are publishing on.

SEE ALSO

POEx::ZMQ3

POEx::ZMQ3::Subscriber

ZMQ::LibZMQ3

http://www.zeromq.org

AUTHOR

Jon Portnoy <avenj@cobaltirc.org>