Does anyone have or know of Perl modules to publish data to an Apache Pulsar messaging bus?

I don't see any, sorry. However, according to the Plusar docs:

Pulsar's WebSocket API is meant to provide a simple way to interact with Pulsar using languages that do not have an official client library. Through WebSockets you can publish and consume messages and use all the features available in the Java, Go, Python and C++ client libraries.

Here's a simple producer and consumer implemented using Mojolicious, based on the Node.js examples in the above link:

consumer.pl

use Mojo::Base -strict, -signatures; use Mojo::UserAgent; use Mojo::IOLoop; use Mojo::Util qw/b64_decode/; use Data::Dump qw/dd pp/; my $ADDR = 'ws://localhost:8080/ws/v2/consumer/persistent/public/defau +lt/my-topic/my-sub'; say "Opening WebSocket..."; my $ua = Mojo::UserAgent->new; $ua->websocket($ADDR => sub ($ua, $tx) { die 'WebSocket handshake failed!'.pp($tx) unless $tx->is_websocket; $tx->on(finish => sub ($tx, $code, $reason=undef) { say "WebSocket closed ", pp($code, $reason); }); $tx->on(json => sub ($tx, $json) { say "Received: ", pp($json); say "Payload: ", pp( b64_decode($json->{payload}) ); say "Sending ack"; $tx->send({ json => { messageId => $json->{messageId} } }); }); }); Mojo::IOLoop->start unless Mojo::IOLoop->is_running;

producer.pl

use Mojo::Base -strict, -signatures; use Mojo::UserAgent; use Mojo::IOLoop; use Mojo::Util qw/b64_encode/; use Data::Dump qw/dd pp/; my $ADDR = 'ws://localhost:8080/ws/v2/producer/persistent/public/defau +lt/my-topic'; say "Opening WebSocket..."; my $ua = Mojo::UserAgent->new; $ua->websocket($ADDR => sub ($ua, $tx) { die 'WebSocket handshake failed!'.pp($tx) unless $tx->is_websocket; $tx->on(finish => sub ($tx, $code, $reason=undef) { say "WebSocket closed ", pp($code, $reason); }); $tx->on(json => sub ($tx, $json) { say "Received ack: ", pp($json); $tx->finish; # close socket after sending test message }); $tx->send({ json => { payload => b64_encode("Hello World", ''), properties => { key1 => "value1", key2 => "value2", }, context => "1", } }); }); Mojo::IOLoop->start unless Mojo::IOLoop->is_running;

In reply to Re: Apache Pulsar modules by haukex
in thread Apache Pulsar modules by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.