Mojo::...blisher(3pm)
okay bestie, welcome to Mojo::...blisher(3pm) from the User Contributed Perl Documentation set. The actual module in the spotlight is Mojo::RabbitMQ::Client::Publisher, and she's a simple Mojo::RabbitMQ::Client based publisher. π
β¨ NAME β¨
Mojo::RabbitMQ::Client::Publisher β simple Mojo::RabbitMQ::Client based publisher. That's the name, that's the vibe. π
πΈ SYNOPSIS πΈ
use Mojo::RabbitMQ::Client::Publisher;
my $publisher = Mojo::RabbitMQ::Client::Publisher->new(
url => 'amqp://guest:guest@127.0.0.1:5672/?exchange=mojo&routing_key=mojo'
);
$publisher->publish_p(
{encode => { to => 'json'}},
routing_key => 'mojo_mq'
)->then(sub {
say "Message published";
})->catch(sub {
die "Publishing failed"
})->wait;
π¦ DESCRIPTION π¦
The original page has literally no description prose here β just the heading. No extra lore, no secret tea. We're not gonna invent any, bestie. Moving on. π
π ATTRIBUTES π
Mojo::RabbitMQ::Client::Publisher has following attributes.
π url π
Sets all connection parameters in one string, according to specification from <https://www.rabbitmq.com/uri-spec.html>.
For detailed description please see Mojo::RabbitMQ::Client#url.
π METHODS π
Mojo::RabbitMQ::Client::Publisher implements only single method. Yes, one. Minimalist queen. β¨
π
publish_p π
$publisher->publish_p('simple plain text body');
$publisher->publish_p({ some => 'json' });
$publisher->publish_p($body, { header => 'content' }, routing_key => 'mojo', mandatory => 1);
Method signature:
publish_p($body!, \%headers?, *@params)
π body π
First argument is mandatory body content of published message. Any reference passed here will be encoded as JSON and accordingly content_type header will be set to application/json.
π§ headers π§
If second argument is a HASHREF it will be merged to message headers.
π₯ params π₯
Any other arguments will be considered key/value pairs and passed to the Client's publish method as arguments overriding everything besides body argument.
So this:
$publisher->publish({ json => 'object' }, { header => 'content' });
is similar to this:
$publisher->publish({ json => 'object' }, header => { header => 'content' });
π¨ Beware, bestie: headers passed as a HASHREF get merged into the header constructed by the Publisher, but params override values; so if you passheaderas a param like this, it will override the header constructed by the Publisher, and the message will lack thecontent_typeheader, even though you passed a reference as the body argument! With the first example, thecontent_typeheader would be included.
π«Ά SEE ALSO π«Ά
Mojo::RabbitMQ::Client
π COPYRIGHT AND LICENSE π
Copyright (C) 2015-2017, Sebastian Podjasek and others
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
Signed, sealed, and slayed at the very end: perl v5.42.0, dated 2019-08-25, page Mojo::...blisher(3pm). πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Mojo-RabbitMQ-Client 0.3.1-bp160.1.4 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms