IO-Iron

 view release on metacpan or  search on metacpan

lib/IO/Iron/IronMQ/Client.pm  view on Meta::CPAN

	my @msg_send_ids = $iron_mq_queue->post_messages( 'messages' => [ $iron_mq_msg_send_01, $iron_mq_msg_send_02 ] );
	my $number_of_msgs_sent = $iron_mq_queue->post_messages( 'messages' => [ $iron_mq_msg_send_01, $iron_mq_msg_send_02 ] );

Read one or more messages from the queue and reserve them so another process
cannot access them. Parameters: n (number of messages you want, default 1,
maximum 100; if there is less, all available messages will be returned),
if no messages, an empty list will be returned,
timeout (After timeout (in seconds), item will be placed back onto queue,
default is 60 seconds, minimum is 30 seconds, and maximum is 86,400 seconds (24 hours)).

	my @iron_mq_msg_pulls = $iron_mq_queue->reserve_messages( n => 10, timeout => 120 );

Read one or more messages from the queue but don't reserve them.
Parameters: n (number of messages you want, default 1, maximum 100; if there
is less, all available messages will be returned),
if no messages, an empty list will be returned.

	my @iron_mq_msg_peeks = $iron_mq_queue->peek( n => 10 );

Delete one or more messages from the queue. Call this when you have
processed the messages. Returns the ids of the messages deleted
or the number of deleted messages.

	my $deleted_msg_id = $iron_mq_queue->delete( 'ids' => [ $msg_id_01 ] );
	my @deleted_msg_ids = $iron_mq_queue->delete( 'ids' => [ $msg_id_01, $msg_id_02 ] );
	my $number_of_msgs_deleted = $iron_mq_queue->delete( 'ids' => [ $msg_id_01, $msg_id_02 ] );

Release one or more messages back to the queue.
Releasing a reserved message unreserves the message and puts
it back on the queue as if the message had timed out.
Delay: The item will not be available on the queue until this
many seconds have passed. Default is 0 seconds.
Maximum is 604,800 seconds (7 days).

Returns 1.

	my $released_msg = $iron_mq_queue->release( 'id' => $msg_id_01, 'delay' => $delay );

Touch one or more messages in the queue. Touching a reserved message extends
its timeout to the duration specified when the message was created.
Default is 60 seconds.
Returns 1.

	my $touched_msg = $iron_mq_queue->touch_message( 'id' => $msg_id_01 );

Clear all messages from the queue: delete all messages,
whether they are reserved or not.

	my $cleared = $iron_mq_queue->clear_messages();

Get queue size.

	my $size = $iron_mq_queue->size();

=head3 Push Queue Commands

Get push status for a message. Retrieve the push status for a
particular message which will let you know which subscribers
have received the message, which have failed, how many times
it's tried to be delivered and the status code returned from
the endpoint.

	my $info = $iron_mq_queue->get_push_statuses( 'id' => $msg_id );
	my @subscribers = (@{info->{'subscribers'}});

Acknowledge / Delete Push Message for a Subscriber.
This is only for use with long running processes that have
previously returned a 202.

	my $info = $iron_mq_queue->get_push_statuses( 'id' => $msg_id );
	my @subscribers = (@{info->{'subscribers'}});
	my $push_acknowledged = $iron_mq_queue->delete_push_message(
		'id' => $msg_id, 'subscriber' => $subscribers[0]->{'id'}
		);

Add Subscribers to a Queue.

	my $add_ret_val = $iron_mq_queue->add_subscribers(
			'name' => $queue_name,
			'subscribers' => [
				{ 'url' => "ironmq://project_id:token\@host/queue_name" },
				{ 'url' => "ironmq:///$queue_name_02" },
			],
		);

Remove Subscribers from a Queue

	my $del_ret_val = $iron_mq_client->delete_subscribers(
			'name' => $queue_name,
			'subscribers' => [
				{ 'url' => "ironmq:///$queue_name" },
			],
		);

=head3 Queue Alerts

Add Alerts to a Queue. This is for Pull Queue only.

	my $alert_added = $iron_mq_client->add_alerts(
		'name' => $normal_queue->name(),
		'alerts' => [
				{
					'type' => 'fixed',
					'queue' => $alert_queue->name(),
					'trigger' => 1,
					'direction' => 'asc',
					'snooze' => 0,
				}
			],
		);

Replace alerts. Change the existing alerts to the given ones.

	my $alert_replaced = $iron_mq_client->replace_alerts(
		'name' => $normal_queue->name(),
		'alerts' => [
				{
					'type' => 'fixed',
					'queue' => $alert_queue->name(),
					'trigger' => 2,
					'direction' => 'desc',



( run in 0.840 second using v1.01-cache-2.11-cpan-524268b4103 )