Amazon-SQS-ProducerConsumer
view release on metacpan or search on metacpan
lib/Amazon/SQS/Consumer.pm view on Meta::CPAN
package Amazon::SQS::Consumer;
use 5.006;
use strict;
use warnings;
use base 'Amazon::SQS::ProducerConsumer::Base';
use JSON::XS;
use Encode qw( encode_utf8 is_utf8 );
use constant {
DEFAULT_N_MESSAGES => 10,
DEFAULT_WAIT_SECONDS => 30,
SECONDS_BETWEEN_TRIES => 10
};
=head1 NAME
Amazon::SQS::Consumer - Receive messages from an Amazon Simple Queue Service (SQS) queue
=cut
sub say (@) { warn join ' ', (split ' ', scalar localtime)[2,1,4,3], "[$$]", (split '/', $0)[-1], @_, "\n"; return @_; }
$SIG{INT} = sub { say 'caught signal INT'; exit 0; };
$SIG{CHLD} = 'IGNORE';
=head1 SYNOPSIS
use Amazon::SQS::Consumer;
my $in_queue = new Amazon::SQS::Consumer
AWSAccessKeyId => 'PUBLIC_KEY_HERE',
SecretAccessKey => 'SECRET_KEY_HERE',
queue => 'YourInputQueue';
while ( my $item = $in_queue->next ) {
# Do stuff with the item
}
=head1 METHODS
=head2 new(%params)
This is the constructor, it will return you an Amazon::SQS::Consumer object to work with. It takes these parameters:
=over
=item AWSAccessKeyId (required)
Your AWS access key.
=item SecretAccessKey (required)
Your secret key, WARNING! don't give this out or someone will be able to use your account and incur charges on your behalf.
=item queue (required)
The URL of the queue to receive messages from.
=item wait_seconds (optional)
The number of seconds to wait for a new message when the queue is empty.
=item debug (optional)
A flag to turn on debugging. It is turned off by default.
=back
( run in 1.531 second using v1.01-cache-2.11-cpan-6aa56a78535 )