1Mojo::RabbitMQ::Client:U:sMeerthCoodn(t3rpimb)uted PerlMDoojcou:m:eRnatbabtiitoMnQ::Client::Method(3pm)
2
3
4
6 Mojo::RabbitMQ::Client::Method - it's a generic class for all AMQP
7 method calls
8
10 use Mojo::RabbitMQ::Client::Method;
11
12 my $method = Mojo::RabbitMQ::Client::Method->new(
13 client => $client,
14 channel => $channel
15 )->setup(
16 'Basic::Consume' => {
17 ...
18 },
19 ['Basic::ConsumeOk', ...]
20 );
21
22 # Watch for errors
23 $method->on(error => sub { warn "Error in reception: " . $_[1] });
24
25 # Send this frame to AMQP
26 $method->deliver;
27
29 Mojo::RabbitMQ::Client::Method is general class for every AMQP method
30 call.
31
33 Mojo::RabbitMQ::Client::Method inherits all events from
34 Mojo::EventEmitter and can emit the following new ones.
35
36 success
37 $method->on(success => sub {
38 my ($method, $frame) = @_;
39 ...
40 });
41
42 Emitted when one of expected replies is received.
43
44 message
45 Can be emitted by consumption & get methods.
46
47 empty
48 Can be emitted by get method, when no messages are available on queue.
49
51 Mojo::RabbitMQ::Client::Method has following attributes.
52
53 is_sent
54 $method->is_sent ? "Method was sent" : "Method is still pending delivery";
55
56 client
57 my $client = $method->client;
58 $method->client($client);
59
60 name
61 my $name = $method->name;
62 $method->name('Basic::Get');
63
64 arguments
65 my $arguments = $method->arguments;
66 $method->arguments({no_ack => 1, ticket => 0, queue => 'amq.queue'});
67
68 expect
69 my $expectations = $method->expect;
70 $method->expect([qw(Basic::GetOk Basic::GetEmpty)]);
71
73 Mojo::RabbitMQ::Client::Method inherits all methods from
74 Mojo::EventEmitter and implements the following new ones.
75
76 setup
77 $method = $method->setup($name, $arguments, $expectations);
78
79 Sets AMQP method name, its arguments and expected replies.
80
81 deliver
82 my $status = $method->deliver();
83
84 This delivers AMQP method call to server. Returns C<<false>> when channel is not open, C<<true>> otherwise.
85 On successful delivery->reply cycle emits C<<success>> event.
86 C<<error>> is emitted when none of expected replies are received.
87
89 Mojo::RabbitMQ::Client::Channel, Mojo::RabbitMQ::Client
90
92 Copyright (C) 2015-2017, Sebastian Podjasek and others
93
94 Based on AnyEvent::RabbitMQ - Copyright (C) 2010 Masahito Ikuta,
95 maintained by "bobtfish@bobtfish.net"
96
97 This program is free software, you can redistribute it and/or modify it
98 under the terms of the Artistic License version 2.0.
99
100
101
102perl v5.34.0 2022-01-21Mojo::RabbitMQ::Client::Method(3pm)