| 1 | package Net::AMQP::RabbitMQ; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 29 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 29 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 29 | our $VERSION = '2.40000'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 29 | ▶ | use XSLoader; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 29 | XSLoader::load "Net::AMQP::RabbitMQ", $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 29 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | # Hash::FieldHash and/or Hash::Util's fieldhash may or may not be available | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # On versions earlier than 5.9.4, Hash::Util::FieldHash didn't exist and | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # hence Hash::Util::fieldhash didn't either. | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # We need one of them to fix #151: REQUEST: optionally leave connection alive | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # in net_amqp_rabbitmq_DESTROY to allow forking | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # | ||||||||||||||||||||||||||||||||||||||||||
| 19 | # If neither is found #151 will remain unfixed | ||||||||||||||||||||||||||||||||||||||||||
| 20 | my $have_fieldhash = eval { | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 29 | require Hash::FieldHash; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | Hash::FieldHash->import('fieldhash'); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 29 | ▶ | } || eval { | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
require Hash::FieldHash;
'Hash::FieldHash'->import('fieldhash');
1
}
} || eval {
do {
require Hash::Util;
'Hash::Util'->import('fieldhash');
1
}
}
MC/DC0%0/2
eval {
do {
require Hash::FieldHash;
'Hash::FieldHash'->import('fieldhash');
1
}
} || eval {
do {
require Hash::Util;
'Hash::Util'->import('fieldhash');
1
}
}
eval {
do {
require Hash::FieldHash;
'Hash::FieldHash'->import('fieldhash');
1
}
}
eval {
do {
require Hash::Util;
'Hash::Util'->import('fieldhash');
1
}
}
Truth table33%1/3
A || B
A= eval {
do {
require Hash::FieldHash;
'Hash::FieldHash'->import('fieldhash');
1
}
}B= eval {
do {
require Hash::Util;
'Hash::Util'->import('fieldhash');
1
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 29 | require Hash::Util; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 29 | Hash::Util->import('fieldhash'); | |||||||||||||||||||||||||||||||||||||||||
| 27 | 29 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 28 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | Net::AMQP::RabbitMQ - interact with RabbitMQ over AMQP using librabbitmq | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | use Net::AMQP::RabbitMQ; | ||||||||||||||||||||||||||||||||||||||||||
| 39 | my $mq = Net::AMQP::RabbitMQ->new(); | ||||||||||||||||||||||||||||||||||||||||||
| 40 | $mq->connect("localhost", { user => "guest", password => "guest" }); | ||||||||||||||||||||||||||||||||||||||||||
| 41 | $mq->channel_open(1); | ||||||||||||||||||||||||||||||||||||||||||
| 42 | $mq->queue_declare(1, "queuename"); | ||||||||||||||||||||||||||||||||||||||||||
| 43 | $mq->publish(1, "queuename", "Hi there!"); | ||||||||||||||||||||||||||||||||||||||||||
| 44 | my $gotten = $mq->get(1, "queuename"); | ||||||||||||||||||||||||||||||||||||||||||
| 45 | print $gotten->{body} . "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 46 | $mq->disconnect(); | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | C<Net::AMQP::RabbitMQ> provides a simple wrapper around the librabbitmq library | ||||||||||||||||||||||||||||||||||||||||||
| 51 | that allows connecting, declaring exchanges and queues, binding and unbinding | ||||||||||||||||||||||||||||||||||||||||||
| 52 | queues, publishing, consuming and receiving events. | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | Error handling in this module is primarily achieve by C<Perl_croak> (die). You | ||||||||||||||||||||||||||||||||||||||||||
| 55 | should be making good use of C<eval> around these methods to ensure that you | ||||||||||||||||||||||||||||||||||||||||||
| 56 | appropriately catch the errors. | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | All methods, unless specifically stated, return nothing on success | ||||||||||||||||||||||||||||||||||||||||||
| 61 | and die on failure. | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | Failure to be connected is a fatal failure for most methods. | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | =head2 new() | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | Creates a new Net::AMQP::RabbitMQ object. | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | =head2 connect( $hostname, $options ) | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | Connect to RabbitMQ server. | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | C<$hostname> is the host to which a connection will be attempted. | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | C<$options> is an optional hash respecting the following keys: | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | user => $user, #default 'guest' | ||||||||||||||||||||||||||||||||||||||||||
| 79 | password => $password, #default 'guest' | ||||||||||||||||||||||||||||||||||||||||||
| 80 | port => $port, #default 5672 | ||||||||||||||||||||||||||||||||||||||||||
| 81 | vhost => $vhost, #default '/' | ||||||||||||||||||||||||||||||||||||||||||
| 82 | channel_max => $cmax, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 83 | frame_max => $fmax, #default 131072 | ||||||||||||||||||||||||||||||||||||||||||
| 84 | heartbeat => $hearbeat, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 85 | timeout => $seconds #default undef (no timeout) | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | ssl => 1 | 0 #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 88 | ssl_verify_host => 1 | 0 #default 1 | ||||||||||||||||||||||||||||||||||||||||||
| 89 | ssl_cacert => $caert_path #needed for ssl | ||||||||||||||||||||||||||||||||||||||||||
| 90 | ssl_init => 1 | 0 #default 1, initilise the openssl library | ||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | You probably don't want to touch C<ssl_init>, unless you know what it does. | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | For now there is no option to disable ssl peer checking, meaning to use C<ssl>, C<ssl_cacert> is required. | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | B<SSL NOTE> | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | if the connection is cut when using ssl, openssl will throw a C<SIGPIPE>, you should catch this or perl | ||||||||||||||||||||||||||||||||||||||||||
| 100 | will exit with error code 141 | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | $SIG{PIPE} = 'IGNORE'; | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | =head2 disconnect() | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | Disconnect from the RabbitMQ server. | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | =head2 get_server_properties() | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | Get a reference to hash (hashref) of server properties. These may vary, you should use C<Data::Dumper> to inspect. Properties will be provided for the RabbitMQ server to which you are connected. | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | =head2 get_client_properties() | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | Get a reference to hash (hashref) of client properties. These may vary, you should use C<Data::Dumper> to inspect. | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | =head2 is_connected() | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | Returns true if a valid socket connection appears to exist, false otherwise. | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | =head2 channel_open($channel) | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | Open an AMQP channel on the connection. | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | C<$channel> is a positive integer describing the channel you which to open. | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | =head2 channel_close($channel) | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | Close the specified channel. | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | C<$channel> is a positive integer describing the channel you which to close. | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | =head2 get_channel_max() | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | Returns the maximum allowed channel number. | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | =head2 exchange_declare($channel, $exchange, $options, $arguments) | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | Declare an AMQP exchange on the RabbitMQ server unless it already exists. Bad | ||||||||||||||||||||||||||||||||||||||||||
| 139 | things will happen if the exchange name already exists and different parameters | ||||||||||||||||||||||||||||||||||||||||||
| 140 | are provided. | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | C<$exchange> is the name of the exchange to be instantiated. | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | C<$options> is an optional hash respecting the following keys: | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | { | ||||||||||||||||||||||||||||||||||||||||||
| 149 | exchange_type => $type, #default 'direct' | ||||||||||||||||||||||||||||||||||||||||||
| 150 | passive => $boolean, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 151 | durable => $boolean, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 152 | auto_delete => $boolean, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | Note that the default for the C<auto_delete> option is different for C<exchange_declare> and for C<queue_declare>. | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | C<$arguments> is an optional hash of additional arguments to the RabbitMQ server, such as: | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | { | ||||||||||||||||||||||||||||||||||||||||||
| 160 | # exchange to try if no routes apply on this exchange | ||||||||||||||||||||||||||||||||||||||||||
| 161 | alternate_exchange => 'alternate_exchange_name', | ||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | =head2 exchange_delete($channel, $exchange, $options) | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | Delete a AMQP exchange on the RabbitMQ server. | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | C<$exchange> is the name of the exchange to be deleted. | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | C<$options> is an optional hash respecting the following keys: | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||
| 175 | if_unused => $boolean, #default 1 | ||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | =head2 exchange_bind($channel, $destination, $source, $routing_key, $arguments) | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | Bind a source exchange to a destination exchange with a given routing key and/or parameters. | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | C<$destination> is a previously declared exchange, C<$source> is | ||||||||||||||||||||||||||||||||||||||||||
| 185 | yet another previously declared exchange, and C<$routing_key> is | ||||||||||||||||||||||||||||||||||||||||||
| 186 | the routing key that will bind the specified source exchange to | ||||||||||||||||||||||||||||||||||||||||||
| 187 | the specified destination exchange. | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | C<$arguments> is an optional hash which will be passed to the server. When | ||||||||||||||||||||||||||||||||||||||||||
| 190 | binding to an exchange of type C<headers>, this can be used to only receive | ||||||||||||||||||||||||||||||||||||||||||
| 191 | messages with the supplied header values. | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | =head2 exchange_unbind($channel, $destination, $source, $routing_key, $arguments) | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | Remove a binding between source and destination exchanges. | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | C<$destination> is a previously declared exchange, C<$source> is | ||||||||||||||||||||||||||||||||||||||||||
| 200 | yet another previously declared exchange, and C<$routing_key> is | ||||||||||||||||||||||||||||||||||||||||||
| 201 | the routing key that will B<unbind> the specified source exchange from | ||||||||||||||||||||||||||||||||||||||||||
| 202 | the specified destination exchange. | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | C<$arguments> is an optional hash which will be passed to the server. When | ||||||||||||||||||||||||||||||||||||||||||
| 205 | binding to an exchange of type C<headers>, this can be used to only receive | ||||||||||||||||||||||||||||||||||||||||||
| 206 | messages with the supplied header values. | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | =head2 queue_declare($channel, $queuename, $options, $arguments) | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | Declare an AMQP queue on the RabbitMQ server. | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | In scalar context, this method returns the queuename declared | ||||||||||||||||||||||||||||||||||||||||||
| 213 | (important for retrieving the auto-generated queuename in the | ||||||||||||||||||||||||||||||||||||||||||
| 214 | event that one was requested). | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | In array context, this method returns three items: queuename, | ||||||||||||||||||||||||||||||||||||||||||
| 217 | the number of message waiting on the queue, and the number | ||||||||||||||||||||||||||||||||||||||||||
| 218 | of consumers bound to the queue. | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | C<$queuename> is the name of the queuename to be instantiated. If | ||||||||||||||||||||||||||||||||||||||||||
| 223 | C<$queuename> is undef or an empty string, then an auto generated | ||||||||||||||||||||||||||||||||||||||||||
| 224 | queuename will be used. | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | C<$options> is an optional hash respecting the following keys: | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | { | ||||||||||||||||||||||||||||||||||||||||||
| 229 | passive => $boolean, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 230 | durable => $boolean, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 231 | exclusive => $boolean, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 232 | auto_delete => $boolean, #default 1 | ||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | Note that the default for the C<auto_delete> option is different for C<exchange_declare> and for C<queue_declare>. | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | C<$arguments> is an optional hash which will be passed to the server | ||||||||||||||||||||||||||||||||||||||||||
| 238 | when the queue is created. This can be used for creating mirrored | ||||||||||||||||||||||||||||||||||||||||||
| 239 | queues by using the x-ha-policy header. | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | =head2 queue_bind($channel, $queuename, $exchange, $routing_key, $arguments) | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | Bind the specified queue to the specified exchange with a routing key. | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | C<$queuename> is a previously declared queue, C<$exchange> is a | ||||||||||||||||||||||||||||||||||||||||||
| 248 | previously declared exchange, and C<$routing_key> is the routing | ||||||||||||||||||||||||||||||||||||||||||
| 249 | key that will bind the specified queue to the specified exchange. | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | C<$arguments> is an optional hash which will be passed to the server. When | ||||||||||||||||||||||||||||||||||||||||||
| 252 | binding to an exchange of type C<headers>, this can be used to only receive | ||||||||||||||||||||||||||||||||||||||||||
| 253 | messages with the supplied header values. | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | =head2 queue_unbind($channel, $queuename, $exchange, $routing_key, $arguments) | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | Remove a binding between a queue and an exchange. If this fails, you must reopen the channel. | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | This is like the C<queue_bind> with respect to arguments. This command unbinds | ||||||||||||||||||||||||||||||||||||||||||
| 260 | the queue from the exchange. The C<$routing_key> and C<$arguments> must match | ||||||||||||||||||||||||||||||||||||||||||
| 261 | the values supplied when the binding was created. | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | =head2 queue_delete($channel, $queuename, $options) | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | Delete a specified queue. If this fails, you must reopen the channel. | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | C<$options> is an optional hash respecting the following keys: | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | { | ||||||||||||||||||||||||||||||||||||||||||
| 270 | if_unused => $boolean, #default 1 | ||||||||||||||||||||||||||||||||||||||||||
| 271 | if_empty => $boolean, #default 1 | ||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | =head2 publish($channel, $routing_key, $body, $options, $props) | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | Publish a message to an exchange. | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | C<$routing_key> is the name of the routing key for this message. | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | C<$body> is the payload to enqueue. | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | C<$options> is an optional hash respecting the following keys: | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | { | ||||||||||||||||||||||||||||||||||||||||||
| 287 | exchange => $exchange, #default 'amq.direct' | ||||||||||||||||||||||||||||||||||||||||||
| 288 | mandatory => $boolean, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 289 | immediate => $boolean, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 290 | force_utf8_in_header_strings => $boolean, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | The C<force_utf8_in_header_strings> option causes all headers which look like | ||||||||||||||||||||||||||||||||||||||||||
| 294 | strings to be treated as UTF-8. In an attempt to make this a non-breaking change, | ||||||||||||||||||||||||||||||||||||||||||
| 295 | this option is disabled by default. However, for all headers beginning with | ||||||||||||||||||||||||||||||||||||||||||
| 296 | C<x->, those are treated as UTF-8 regardless of this option (per spec). | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | C<$props> is an optional hash (the AMQP 'props') respecting the following keys: | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | content_type => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 302 | content_encoding => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 303 | correlation_id => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 304 | reply_to => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 305 | expiration => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 306 | message_id => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 307 | type => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 308 | user_id => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 309 | app_id => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 310 | delivery_mode => $integer, | ||||||||||||||||||||||||||||||||||||||||||
| 311 | priority => $integer, | ||||||||||||||||||||||||||||||||||||||||||
| 312 | timestamp => $integer, | ||||||||||||||||||||||||||||||||||||||||||
| 313 | headers => $headers # This should be a hashref of keys and values. | ||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | =head2 consume($channel, $queuename, $options) | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | Put the channel into consume mode. | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | The C<consumer_tag> is returned. This command does B<not> return AMQP | ||||||||||||||||||||||||||||||||||||||||||
| 321 | messages, for that the C<recv> method should be used. | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | C<$queuename> is the name of the queue from which we'd like to consume. | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | C<$options> is an optional hash respecting the following keys: | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | { | ||||||||||||||||||||||||||||||||||||||||||
| 330 | consumer_tag => $tag, #absent by default | ||||||||||||||||||||||||||||||||||||||||||
| 331 | no_local => $boolean, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 332 | no_ack => $boolean, #default 1 | ||||||||||||||||||||||||||||||||||||||||||
| 333 | exclusive => $boolean, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | =head2 recv($timeout) | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | Receive AMQP messages. | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | This method returns a reference to a hash (hashref) containing the following information: | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | { | ||||||||||||||||||||||||||||||||||||||||||
| 343 | body => 'Magic Transient Payload', # the reconstructed body | ||||||||||||||||||||||||||||||||||||||||||
| 344 | routing_key => 'nr_test_q', # route the message took | ||||||||||||||||||||||||||||||||||||||||||
| 345 | exchange => 'nr_test_x', # exchange used | ||||||||||||||||||||||||||||||||||||||||||
| 346 | delivery_tag => 1, # (used for acks) | ||||||||||||||||||||||||||||||||||||||||||
| 347 | redelivered => $boolean # if message is redelivered | ||||||||||||||||||||||||||||||||||||||||||
| 348 | consumer_tag => 'c_tag', # tag from consume() | ||||||||||||||||||||||||||||||||||||||||||
| 349 | props => $props, # hashref sent in | ||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | C<$props> is the hash sent by publish() respecting the following keys: | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | { | ||||||||||||||||||||||||||||||||||||||||||
| 355 | content_type => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 356 | content_encoding => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 357 | correlation_id => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 358 | reply_to => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 359 | expiration => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 360 | message_id => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 361 | type => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 362 | user_id => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 363 | app_id => $string, | ||||||||||||||||||||||||||||||||||||||||||
| 364 | delivery_mode => $integer, | ||||||||||||||||||||||||||||||||||||||||||
| 365 | priority => $integer, | ||||||||||||||||||||||||||||||||||||||||||
| 366 | timestamp => $integer, | ||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | C<$timeout> is a positive integer, specifying the number of milliseconds to | ||||||||||||||||||||||||||||||||||||||||||
| 370 | wait for a message. If you do not provide a timeout (or set it to 0), then | ||||||||||||||||||||||||||||||||||||||||||
| 371 | this call will block until it receives a message. If you set it to -1 it will | ||||||||||||||||||||||||||||||||||||||||||
| 372 | return immediately (waiting 0 ms). | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | If you provide a timeout, then the C<recv> method returns C<undef> if the | ||||||||||||||||||||||||||||||||||||||||||
| 375 | timeout expires before a message is received from the server. | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | =head2 cancel($channel, $consumer_tag) | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | Take the channel out of consume mode previously enabled with C<consume>. | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | This method returns true or false indicating whether we got the expected | ||||||||||||||||||||||||||||||||||||||||||
| 382 | "cancel-ok" response from the server. | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | C<$consumer_tag> is a tag previously passed to C<consume()> or one that was | ||||||||||||||||||||||||||||||||||||||||||
| 387 | generated automatically as a result of calling C<consume()> without an | ||||||||||||||||||||||||||||||||||||||||||
| 388 | explicit tag. | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | =head2 get($channel, $queuename, $options) | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | Get a message from the specified queue (via C<amqp_basic_get()>). | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | The method returns C<undef> immediately if no messages are available | ||||||||||||||||||||||||||||||||||||||||||
| 395 | on the queue. If a message is available a reference to a hash (hashref) is | ||||||||||||||||||||||||||||||||||||||||||
| 396 | returned with the following contents: | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | { | ||||||||||||||||||||||||||||||||||||||||||
| 399 | body => 'Magic Transient Payload', # the reconstructed body | ||||||||||||||||||||||||||||||||||||||||||
| 400 | routing_key => 'nr_test_q', # route the message took | ||||||||||||||||||||||||||||||||||||||||||
| 401 | exchange => 'nr_test_x', # exchange used | ||||||||||||||||||||||||||||||||||||||||||
| 402 | content_type => 'foo', # (only if specified) | ||||||||||||||||||||||||||||||||||||||||||
| 403 | delivery_tag => 1, # (used for acks) | ||||||||||||||||||||||||||||||||||||||||||
| 404 | redelivered => 0, # if message is redelivered | ||||||||||||||||||||||||||||||||||||||||||
| 405 | message_count => 0, # message count | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | # Not all of these will be present. Consult the RabbitMQ reference for more details. | ||||||||||||||||||||||||||||||||||||||||||
| 408 | props => { | ||||||||||||||||||||||||||||||||||||||||||
| 409 | content_type => 'text/plain', | ||||||||||||||||||||||||||||||||||||||||||
| 410 | content_encoding => 'none', | ||||||||||||||||||||||||||||||||||||||||||
| 411 | correlation_id => '123', | ||||||||||||||||||||||||||||||||||||||||||
| 412 | reply_to => 'somequeue', | ||||||||||||||||||||||||||||||||||||||||||
| 413 | expiration => 1000, | ||||||||||||||||||||||||||||||||||||||||||
| 414 | message_id => 'ABC', | ||||||||||||||||||||||||||||||||||||||||||
| 415 | type => 'notmytype', | ||||||||||||||||||||||||||||||||||||||||||
| 416 | user_id => 'guest', | ||||||||||||||||||||||||||||||||||||||||||
| 417 | app_id => 'idd', | ||||||||||||||||||||||||||||||||||||||||||
| 418 | delivery_mode => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 419 | priority => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 420 | timestamp => 1271857990, | ||||||||||||||||||||||||||||||||||||||||||
| 421 | headers => { | ||||||||||||||||||||||||||||||||||||||||||
| 422 | unsigned_integer => 12345, | ||||||||||||||||||||||||||||||||||||||||||
| 423 | signed_integer => -12345, | ||||||||||||||||||||||||||||||||||||||||||
| 424 | double => 3.141, | ||||||||||||||||||||||||||||||||||||||||||
| 425 | string => "string here", | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | # The x-death header is a special header for dead-lettered messages (rejected or timed out). | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 'x-death' => [ | ||||||||||||||||||||||||||||||||||||||||||
| 429 | { | ||||||||||||||||||||||||||||||||||||||||||
| 430 | time => 1271857954, | ||||||||||||||||||||||||||||||||||||||||||
| 431 | exchange => $exchange, | ||||||||||||||||||||||||||||||||||||||||||
| 432 | queue => $exchange, | ||||||||||||||||||||||||||||||||||||||||||
| 433 | reason => 'expired', | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 'routing-keys' => [q{}], | ||||||||||||||||||||||||||||||||||||||||||
| 435 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 436 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 437 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 438 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | C<$queuename> is the name of the queue from which we'd like to consume. | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | C<$options> is an optional hash respecting the following keys: | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | { | ||||||||||||||||||||||||||||||||||||||||||
| 448 | no_ack => $boolean, #default 1 | ||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | =head2 ack($channel, $delivery_tag, $multiple = 0) | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | Acknowledge a message. | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | C<$delivery_tag> the delivery tag seen from a returned message from the | ||||||||||||||||||||||||||||||||||||||||||
| 458 | C<recv> method. | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | C<$multiple> specifies if multiple are to be acknowledged at once. | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | =head2 purge($channel, $queuename) | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | Purge all messages from the specified queue. | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | C<$queuename> is the queue to be purged. | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | =head2 reject($channel, $delivery_tag, $requeue = 0) | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | Reject a message with the specified delivery tag. | ||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | C<$delivery_tag> the delivery tag seen from a returned message from the | ||||||||||||||||||||||||||||||||||||||||||
| 477 | C<recv> method. | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | C<$requeue> specifies if the message should be requeued. | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | =head2 tx_select($channel) | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | Start a server-side (tx) transaction over $channel. | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | =head2 tx_commit($channel) | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | Commit a server-side (tx) transaction over $channel. | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | =head2 tx_rollback($channel) | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | Rollback a server-side (tx) transaction over $channel. | ||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | =head2 basic_qos($channel, $options) | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | Set quality of service flags on the current $channel. | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | C<$channel> is a channel that has been opened with C<channel_open>. | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | C<$options> is an optional hash respecting the following keys: | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | { | ||||||||||||||||||||||||||||||||||||||||||
| 508 | prefetch_count => $cnt, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 509 | prefetch_size => $size, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 510 | global => $bool, #default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | =head2 heartbeat() | ||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | Send a heartbeat. If you've connected with a heartbeat parameter, | ||||||||||||||||||||||||||||||||||||||||||
| 516 | you must send a heartbeat periodically matching connection parameter or | ||||||||||||||||||||||||||||||||||||||||||
| 517 | the server may snip the connection. | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | =head2 has_ssl | ||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | Returns true if the module was compiled with SSL support, false otherwise | ||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | =head1 WARNING AND ERROR MESSAGES | ||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | =head2 Fatal Errors | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | It should be noted that almost all errors in this library are considered fatal, | ||||||||||||||||||||||||||||||||||||||||||
| 528 | insomuch as they trigger a C<croak()>. In these errors, if it appears that somehow | ||||||||||||||||||||||||||||||||||||||||||
| 529 | the connection has been closed by the remote host, or otherwise invalidated, | ||||||||||||||||||||||||||||||||||||||||||
| 530 | the socket will also be closed and should be re-opened before any additional | ||||||||||||||||||||||||||||||||||||||||||
| 531 | calls are made. | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | =head1 EXAMPLES | ||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | =head2 Simple publisher | ||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | use Net::AMQP::RabbitMQ; | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | my $channel = 1; | ||||||||||||||||||||||||||||||||||||||||||
| 540 | my $exchange = "MyExchange.x"; # This exchange must exist already | ||||||||||||||||||||||||||||||||||||||||||
| 541 | my $routing_key = "foobar"; | ||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | my $mq = Net::AMQP::RabbitMQ->new(); | ||||||||||||||||||||||||||||||||||||||||||
| 544 | $mq->connect("localhost", { user => "guest", password => "guest" }); | ||||||||||||||||||||||||||||||||||||||||||
| 545 | $mq->channel_open(1); | ||||||||||||||||||||||||||||||||||||||||||
| 546 | $mq->publish($channel, $routing_key, "Message Here", { exchange => $exchange }); | ||||||||||||||||||||||||||||||||||||||||||
| 547 | $mq->disconnect(); | ||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | =head2 Simple consumer | ||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||
| 551 | use Net::AMQP::RabbitMQ; | ||||||||||||||||||||||||||||||||||||||||||
| 552 | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | my $channel = 1; | ||||||||||||||||||||||||||||||||||||||||||
| 555 | my $exchange = "MyExchange.x"; # This exchange must exist already | ||||||||||||||||||||||||||||||||||||||||||
| 556 | my $routing_key = "foobar"; | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | my $mq = Net::AMQP::RabbitMQ->new(); | ||||||||||||||||||||||||||||||||||||||||||
| 559 | $mq->connect("localhost", { user => "guest", password => "guest" }); | ||||||||||||||||||||||||||||||||||||||||||
| 560 | $mq->channel_open($channel); | ||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | # Declare queue, letting the server auto-generate one and collect the name | ||||||||||||||||||||||||||||||||||||||||||
| 563 | my $queuename = $mq->queue_declare($channel, ""); | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | # Bind the new queue to the exchange using the routing key | ||||||||||||||||||||||||||||||||||||||||||
| 566 | $mq->queue_bind($channel, $queuename, $exchange, $routing_key); | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | # Request that messages be sent and receive them until interrupted | ||||||||||||||||||||||||||||||||||||||||||
| 569 | $mq->consume($channel, $queuename); | ||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | while ( my $message = $mq->recv(0) ) | ||||||||||||||||||||||||||||||||||||||||||
| 572 | { | ||||||||||||||||||||||||||||||||||||||||||
| 573 | print "Received message:\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 574 | print Dumper($message); | ||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | $mq->disconnect(); | ||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | =head1 RUNNING THE TEST SUITE | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | The test suite runs live tests against a RabbitMQ server at | ||||||||||||||||||||||||||||||||||||||||||
| 582 | C<https://www.cloudamqp.com/>. | ||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | There are separte variables for the ssl and none ssl host/user/password/port. | ||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | If you are in an environment that won't let you connect to this | ||||||||||||||||||||||||||||||||||||||||||
| 587 | host (or the test server is down), you can use these environment variables: | ||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||
| 589 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | =item MQHOST | ||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | Hostname or IP address of the RabbitMQ server to connect to (defaults | ||||||||||||||||||||||||||||||||||||||||||
| 594 | to C<hornet.rmq.cloudamqp.com>). | ||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | =item MQUSERNAME | ||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | Username for authentication (defaults to username for L<https://www.cloudamqp.com>). | ||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | =item MQPASSWORD | ||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||
| 602 | Password for authentication (defaults to password for L<https://www.cloudamqp.com>). | ||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||
| 604 | =item MQPORT | ||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||
| 606 | Port of the RabbitMQ server to connect to (defaults to 5672) | ||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | =item MQVHOST | ||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | Vhost to use (defaults to vhost for for L<https://www.cloudamqp.com>). | ||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||
| 612 | =item MQSSL | ||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||
| 614 | Whether the tests should run with SSL enabled (defaults to false, but | ||||||||||||||||||||||||||||||||||||||||||
| 615 | see also C<MQSKIPSSL>). | ||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | =item MQSKIPSSL | ||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | Whether the SSL tests should be skipped entirely. This option exists | ||||||||||||||||||||||||||||||||||||||||||
| 620 | because the SSL tests used to ignore C<MQSSL>, and to maintain | ||||||||||||||||||||||||||||||||||||||||||
| 621 | backwards compatibility, still do. | ||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||
| 623 | =item MQSSLHOST | ||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | Hostname or IP address of the RabbitMQ server to connect to (defaults | ||||||||||||||||||||||||||||||||||||||||||
| 626 | to C<hornet.rmq.cloudamqp.com>). | ||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | =item MQSSLUSERNAME | ||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | Username for authentication (defaults to username for L<https://www.cloudamqp.com>). | ||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | =item MQSSLPASSWORD | ||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | Password for authentication (defaults to password for L<https://www.cloudamqp.com>). | ||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | =item MQSSLPORT | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | Port of the RabbitMQ server to connect to (defaults to 5671) | ||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | =item MQSSLCACERT | ||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | Path to the certificate file for SSL-enabled connections, defaults to | ||||||||||||||||||||||||||||||||||||||||||
| 643 | F<t/ssl/cloudamqp.cacert.pem>. | ||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | =item MQSSLVERIFYHOST | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | Whether SSL hostname verification should be enabled (defaults to | ||||||||||||||||||||||||||||||||||||||||||
| 648 | true). | ||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | =item MQSSLINIT | ||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | Whether the openssl library should be initialized (defaults to true). | ||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | =item MQSSLVHOST | ||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | Vhost to use when in SSL mode (defaults to vhost for for L<https://www.cloudamqp.com>). | ||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||
| 658 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||
| 660 | =head1 VERSION COMPATIBILITY | ||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||
| 662 | This module was forked from L<Net::RabbitMQ> version 0.2.6 which uses an older | ||||||||||||||||||||||||||||||||||||||||||
| 663 | version of librabbitmq, and doesn't work correctly with newer versions of RabbitMQ. | ||||||||||||||||||||||||||||||||||||||||||
| 664 | The main change between this module and the original is this library uses | ||||||||||||||||||||||||||||||||||||||||||
| 665 | a newer, unforked, version of librabbitmq. | ||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | This means this module only works with the AMQP 0.9.1 protocol, so requires RabbitMQ | ||||||||||||||||||||||||||||||||||||||||||
| 668 | version 2+. Also, since the version of librabbitmq used is not a custom fork, it | ||||||||||||||||||||||||||||||||||||||||||
| 669 | means this module doesn't support the basic_return callback method. | ||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | Theo Schlossnagle E<lt>jesus@omniti.comE<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||
| 675 | Mark Ellis E<lt>markellis@cpan.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | Michael Stemle, Jr. E<lt>themanchicken@gmail.comE<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | Dave Rolsky E<lt>autarch@urth.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||
| 681 | Slaven Rezić | ||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | Armand Leclercq | ||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | Daniel W Burke | ||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | Dávid Kovács | ||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||
| 689 | Alexey Sheynuk | ||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | Karen Etheridge E<lt>ether@cpan.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | Eric Brine E<lt>ikegami@cpan.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | Peter Valdemar Mørch E<lt>pmorch@cpan.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | =head1 THANKS | ||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | Special thanks to L<https://www.cloudamqp.com> for providing us with the RabbitMQ server the tests run against. | ||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||
| 701 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | This software is licensed under the Mozilla Public License. See the LICENSE file in the top distribution directory for the full license text. | ||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||
| 705 | librabbitmq is licensed under the MIT License. See the LICENSE-MIT file in the top distribution directory for the full license text. | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | # Since we can't store the PID in $self, which is a amqp_connection_state_t, we | ||||||||||||||||||||||||||||||||||||||||||
| 710 | # store the pid for $self in $pids{$self}. | ||||||||||||||||||||||||||||||||||||||||||
| 711 | # (See L<perlobj#Inside-Out-objects>). | ||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | 29 | my %pids; | |||||||||||||||||||||||||||||||||||||||||
| 714 | 29 | ▶ | if ($have_fieldhash) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 715 | 29 | fieldhash(%pids); | |||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||
| 718 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 719 | 27 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 720 | 27 | my $self = $class->_new(@_); | |||||||||||||||||||||||||||||||||||||||||
| 721 | 27 | ▶ | $pids{$self} = $$ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 722 | if $have_fieldhash; | ||||||||||||||||||||||||||||||||||||||||||
| 723 | 27 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | sub publish { | ||||||||||||||||||||||||||||||||||||||||||
| 727 | 25 | ▶ | my ($self, $channel, $routing_key, $body, $options, $props) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
publish: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | 25 | ▶ | $options ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$options ||= {}
MC/DC0%0/1
$options ||= {}
$options
Truth table50%1/2
A
A= $options
| |||||||||||||||||||||||||||||||||||||||||||
| 730 | 25 | ▶ | $props ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$props ||= {}
MC/DC100%1/1
$props ||= {}
$props
Truth table100%2/2
A
A= $props
| |||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||
| 732 | # Do a shallow clone to avoid modifying variable passed by caller | ||||||||||||||||||||||||||||||||||||||||||
| 733 | 25 | $props = { %$props }; | |||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||
| 735 | # Convert blessed variables in headers to strings | ||||||||||||||||||||||||||||||||||||||||||
| 736 | 25 | ▶ | if( $props->{headers} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 737 | 9 | ▶ | $props->{headers} = { map { blessed($_) ? "$_" : $_ } %{ $props->{headers} } }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | 25 | $self->_publish($channel, $routing_key, $body, $options, $props); | |||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||
| 743 | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||
| 744 | 8 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||
| 745 | $self->_destroy_connection_close | ||||||||||||||||||||||||||||||||||||||||||
| 746 | 8 | ▶ | if !$have_fieldhash || $pids{$self} && $pids{$self} == $$; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not $have_fieldhash or $pids{$self} and $pids{$self} == $$
$pids{$self} and $pids{$self} == $$
MC/DC33%1/3
not $have_fieldhash or $pids{$self} and $pids{$self} == $$
not $have_fieldhash
$pids{$self}
$pids{$self} == $$
Truth table50%2/4
not(A) or B and C
A= not $have_fieldhashB= $pids{$self}C= $pids{$self} == $$
| |||||||||||||||||||||||||||||||||||||||||||
| 747 | 8 | $self->_destroy_cleanup; | |||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | 29 | 1; | |||||||||||||||||||||||||||||||||||||||||