AnyMQ::Queue - AnyMQ Message Queue
my $channel = AnyMQ->topic('Foo');
my $client = AnyMQ->new_listener($channel);
$client->poll_once(sub {
my @messages = @_;
# ...
});
$client->poll(sub {
my @messages = @_;
# ...
});
An AnyMQ::Queue instance is a queue, each message put into the queue can be
consumed exactly once. It's used as the client (or the subscriber in terms of
pub/sub) in AnyMQ. An AnyMQ::Queue can subscribe to multiple AnyMQ::Topic.
Subscribe to a AnyMQ::Topic object.
This is the event-driven poll mechanism, which accepts a callback. Messages are
streamed to $code_ref passed in.
Cancels a running "poll", which will result in "on_timeout"
being called.
This method returns all messages since the last poll to
$code_ref. It blocks for
$timeout seconds if there's currently no messages
available.
Marking the current queue as destroyed or not.
Timeout value for this queue. Default is 55.
Sets the error handler invoked when "poll" or
"poll_once" callbacks fail. By default the
queue is marked as destroyed. If you register this error handler, you should
call "$queue->destroyed(1)" should you
wish to mark the queue as destroyed and reclaim resources.
Note that for queues that are currently
"poll"'ed, you may unset the
"persistent" attribute to avoid the queue
from being destroyed, and can be used for further
"poll" or
"poll_once" calls. In this case,
"on_timeout" will be triggered if
"poll" or
"poll_once" is not called after
"$self->timeout" seconds.
If a queue is not currently polled, this callback will be triggered after
"$self->timeout" seconds. The default
behaviour is marking the queue as destroyed.
Append messages directly to the queue. You probably want to use
"publish" method of AnyMQ::Topic