1Mojo::RabbitMQ::Client:U:sPeurblCiosnhterri(b3uptme)d PeMroljoD:o:cRuambebnittaMtQi:o:nClient::Publisher(3pm)
2
3
4

NAME

6       Mojo::RabbitMQ::Client::Publisher - simple Mojo::RabbitMQ::Client based
7       publisher
8

SYNOPSIS

10         use Mojo::RabbitMQ::Client::Publisher;
11         my $publisher = Mojo::RabbitMQ::Client::Publisher->new(
12           url => 'amqp://guest:guest@127.0.0.1:5672/?exchange=mojo&routing_key=mojo'
13         );
14
15         $publisher->publish_p(
16           {encode => { to => 'json'}},
17           routing_key => 'mojo_mq'
18         )->then(sub {
19           say "Message published";
20         })->catch(sub {
21           die "Publishing failed"
22         })->wait;
23

DESCRIPTION

ATTRIBUTES

26       Mojo::RabbitMQ::Client::Publisher has following attributes.
27
28   url
29       Sets all connection parameters in one string, according to
30       specification from <https://www.rabbitmq.com/uri-spec.html>.
31
32       For detailed description please see Mojo::RabbitMQ::Client#url.
33

METHODS

35       Mojo::RabbitMQ::Client::Publisher implements only single method.
36
37   publish_p
38         $publisher->publish_p('simple plain text body');
39
40         $publisher->publish_p({ some => 'json' });
41
42         $publisher->publish_p($body, { header => 'content' }, routing_key => 'mojo', mandatory => 1);
43
44       Method signature
45
46         publish_p($body!, \%headers?, *@params)
47
48       body
49         First argument is mandatory body content of published message.  Any
50         reference passed here will be encoded as JSON and accordingly
51         "content_type" header will be set to "application/json".
52
53       headers
54         If second argument is a HASHREF it will be merged to message headers.
55
56       params
57         Any other arguments will be considered key/value pairs and passed to
58         the Client's publish method as arguments overriding everything
59         besides body argument.
60
61         So this:
62
63           $publisher->publish({ json => 'object' }, { header => 'content' });
64
65         is similar to this:
66
67           $publisher->publish({ json => 'object' }, header => { header => 'content' });
68
69         But beware - headers passed as a HASHREF get merged into the header
70         constructed by the Publisher, but params override values; so if you
71         pass "header" as a param like this, it will override the header
72         constructed by the Publisher, and the message will lack the
73         "content_type" header, even though you passed a reference as the body
74         argument! With the first example, the "content_type" header would be
75         included.
76

SEE ALSO

78       Mojo::RabbitMQ::Client
79
81       Copyright (C) 2015-2017, Sebastian Podjasek and others
82
83       This program is free software, you can redistribute it and/or modify it
84       under the terms of the Artistic License version 2.0.
85
86
87
88perl v5.38.0                      2023-07M-o2j0o::RabbitMQ::Client::Publisher(3pm)
Impressum