Pub-Sub envelope publisher in Perl


Pubsub envelope publisher

Author: Alexander D'Archangel (darksuji) <darksuji(at)gmail(dot)com>


use strict;
use warnings;
use 5.10.0;

use ZeroMQ qw/:all/;

# Prepare our context and publisher
my $context = ZeroMQ::Context->new();
my $publisher = $context->socket(ZMQ_PUB);

while (1) {
# Write two messages, each with an envelope and content
$publisher->send('A', ZMQ_SNDMORE);
$publisher->send("We don't want to see this");
$publisher->send('B', ZMQ_SNDMORE);
$publisher->send("We would like to see this");
sleep (1);