view release on metacpan or search on metacpan
bin/QueueDaemon.pl view on Meta::CPAN
########################################################################
sub get_options {
########################################################################
my @option_specs = qw(
config|c=s
create-queue|C
daemonize|d!
delete-when|D=s
exit-when|E=s
endpoint_url|e=s
help|h
logfile|L=s
loglevel|l=s
max-children|m=i
max-sleep-time=i
max-messages=i
pidfile|p=s
queue|q=s
queue-interval|I=i
handler|H=s
bin/QueueDaemon.pl view on Meta::CPAN
if ( Class::Inspector->loaded( $options->{handler} ) ) {
Class::Unload->unload( $options->{handler} );
}
autoload $options->{handler};
my $handler = $options->{handler}->new(
config => $config,
logger => $logger,
endpoint_url => $options->{endpoint_url},
name => $options->{queue},
url => $options->{'queue-url'},
message_type => $options->{'message-type'},
create_queue => $options->{'create-queue'},
wait_time => $options->{'wait-time'},
visibility_timeout => $options->{'visibility-timeout'},
credentials => $credentials,
);
die "not an Amazon::SQS::QueueHandler\n"
bin/QueueDaemon.pl view on Meta::CPAN
=head1 OPTIONS
-h, --help help
-c, --config config file name
-C, --create-queue create the queue if it does not exist
-d, --daemonize daemonize the script (default)
--no-daemonize
-D, --delete-when never, always, error
-E, --exit-when never, always, error, false
-e, --endpoint-url default: https://sqs.amazonaws.com
-L, --logfile name of logfile
-l, --loglevel log level (trace, debug, info, warn, error)
-H, --handler name of the handler class, default: Amazon::SQS::QueueHandler
-m, --max-children not implemented (default: 1)
-s, --max-sleep-time default: 5 seconds
--max-messages fixed at 1 currently
-M, --message-type mime type of messages (text/plain, application/json,
application/x-www-form-encoded), default: text/plain
-q, --queue queue name (not url)
--queue-interval amount of time to sleep
bin/create-queue.pl view on Meta::CPAN
return 0;
}
########################################################################
sub init_client {
########################################################################
my ($options) = @_;
my $client_options = {
ServiceURL => $options->{'endpoint-url'},
$options->{debug} ? ( loglevel => 'debug' ) : ( loglevel => 'info' ),
};
my @credentials = ( $ENV{AWS_ACCESS_KEY_ID}, $ENV{AWS_SECRET_ACCESS_KEY} );
return Amazon::SQS::Client->new( @credentials, $client_options );
}
########################################################################
sub main {
########################################################################
my @option_specs = qw(
debug|d
dlq!
delay-seconds|D=i
endpoint-url|e=s
help|h
max-receive-count|c=i
maximum-message-size|S=i
message-retention-period|p=i
queue|q=s
receive-message-wait-time-seconds|w=i
visibility-timeout|v=i
);
my %options = (
dlq => 1,
'delay-seconds' => $DEFAULT_DELAY_SECONDS,
'endpoint-url' => $DEFAULT_ENDPOINT_URL,
'max-receive-count' => $DEFAULT_MAX_RECEIVE_COUNT,
'endpoint-url' => $DEFAULT_ENDPOINT_URL,
'maximum-message-size' => $DEFAULT_MAXIMUM_MESSAGE_SIZE,
'message-retention-period' => $DEFAULT_MESSAGE_RETENTION_PERIOD,
'receive-message-wait-time-seconds' => $DEFAULT_RECEIVE_MESSAGE_WAIT_TIME_SECONDS,
);
my %dispatch = (
attributes => \&command_attributes,
create => \&command_create,
'send-message' => \&command_send_message,
'receive-message' => \&command_receive_message,
bin/create-queue.pl view on Meta::CPAN
=back
=head1 OPTIONS
--help, -h
--queue, -q
Queue name. The dead letter queue will be the same name with a DLQ suffix
--endpoint-url, -e
Endpoint URL Default: https://queue.amazonaws.com
--delay-seconds, -D
Length of time, in seconds, for which the delivery of all messages in
the queue is delayed. Valid values: An integer from 0 to 900 seconds
(15 minutes). Default: 0.
--maximum-message-size, -M
lib/Amazon/SQS/Client.pm view on Meta::CPAN
$data .= $parameterName . $parameters->{$parameterName};
}
return $data;
}
sub _calculateStringToSignV2 {
my ( $self, $parameters, $queueUrl ) = @_;
my $endpoint = URI->new($queueUrl);
my $data = 'POST';
$data .= "\n";
$data .= $endpoint->host;
$data .= "\n";
my $path = $endpoint->path || $SLASH;
$data .= $self->_urlencode( $path, 1 );
$data .= "\n";
my @parameterKeys = keys %{$parameters};
foreach my $parameterName ( sort { $a cmp $b } @parameterKeys ) {
no warnings 'uninitialized'; ## no critic
$data .= $parameterName . $EQUALS . $self->_urlencode( $parameters->{$parameterName} );
$data .= $AMPERSAND;
}
lib/Amazon/SQS/Client.pm view on Meta::CPAN
=item * UserAgent
default: LWP::UserAgent
=item * SignatureVersion
default: 2
I<Note: Signature Version 4 is supported by AWS::Signature4. If you
use the Signature 4 signing facility, make sure your ServiceURL
includes the region endpoint. Ex:
https://sqs.us-east-1.amazonaws.com.>
=item * SecurityToken
For temporary credentials, add the security token returned from the
AWS Security Token Service.
=item * ServiceVersion
default: 2012-11-05
lib/Amazon/SQS/Config.pm view on Meta::CPAN
delay receipt of messages up to the max wait time.
I<NOTE: Using long polling instead of short polling will result in your daemon
blocking until the ReceiveMessage API returns. Signals received during
this period not be may not be immediately acting upon.>
=back
=head2 aws
This section describes the SQS endpoint and your API credentials. By
default, the F<QueueDaemon.pl> script will use the
L<Amazon::Credentials> class to find your credentials so you do not
need to configure them here.
[aws]
access_key_id = <Your Access Key ID>
secret_access_key = <Your Secret Access Key>
endpoint_url = https://sqs.amazonaws.com
=over 5
=item access_key_id
Your AWS Access key value.
=item secrete_access_key
Your AWS Secret Access key value.
=item endpoint_url
The AWS SQS endpoint.
default: https://queue.amazonaws.com
=back
=head2 log
The log section describe how the F<QueueDaemon.pl> script will log
messages. The script instantiates a L<Log::Log4perl> logger
automatically for you that will log to the parent's STDERR. See note
lib/Amazon/SQS/QueueHandler.pm view on Meta::CPAN
use CGI::Simple;
use JSON;
use List::Util qw(none max);
__PACKAGE__->follow_best_practice;
__PACKAGE__->mk_accessors(
qw(
config
create_queue
credentials
endpoint_url
logger
max_error_retry
message
message_id
message_type
message_body
raw_message
receipt_handle
request
region
lib/Amazon/SQS/QueueHandler.pm view on Meta::CPAN
########################################################################
my ($self) = @_;
my $config = $self->get_config;
# init options from config...
if ($config) {
foreach (
qw(
handler_message_type
aws_endpoint_url
queue_max_error_retry
queue_max_messages
queue_url
queue_name
queue_create_queue
queue_visibility_timeout
queue_wait_time
)
) {
my $getter = "get_$_";
lib/Amazon/SQS/QueueHandler.pm view on Meta::CPAN
}
}
my $message_type = $self->get_message_type // 'text/plain';
die "invalid message type\n"
if none { $message_type eq $_ } @VALID_MESSAGE_TYPES;
$self->set_message_type($message_type);
my $endpoint_url //= $self->get_endpoint_url;
$endpoint_url //= $ENV{AWS_ENDPOINT_URL} // $DEFAULT_ENDPOINT_URL;
$self->set_endpoint_url($endpoint_url);
my $max_messages = $self->get_max_messages() || 1;
$self->set_max_messages( max( $MAX_MESSAGES, $max_messages ) );
return;
}
########################################################################
sub create_queue {
lib/Amazon/SQS/QueueHandler.pm view on Meta::CPAN
return %queue_list;
}
########################################################################
sub create_service {
########################################################################
my ($self) = @_;
my %options = (
ServiceURL => $self->get_endpoint_url,
MaxErrorRetry => $self->get_max_error_retry,
credentials => $self->get_credentials,
);
my $service = eval { return Amazon::SQS::Client->new( undef, undef, \%options ); };
die "could not create service\n$EVAL_ERROR"
if !$service || $EVAL_ERROR;
$self->set_service($service);
lib/Amazon/SQS/Sample.pm view on Meta::CPAN
use Amazon::SQS::Client;
use Amazon::SQS::Config;
use Amazon::SQS::Exception;
use Pod::Usage;
use Carp qw( carp croak );
use Data::Dumper;
use English qw(-no_match_vars);
__PACKAGE__->follow_best_practice;
__PACKAGE__->mk_accessors(qw(file service config endpoint_url));
use parent qw(Class::Accessor::Fast);
########################################################################
sub sample {
########################################################################
my ($service) = @_;
return;
}
lib/Amazon/SQS/Sample.pm view on Meta::CPAN
my $self = $class->SUPER::new($options);
my $config;
if ( $self->get_file ) {
$config = Amazon::SQS::Config->new( file => $self->get_file );
$self->set_config($config);
}
my $endpoint_url = $self->get_endpoint_url;
my $service = Amazon::SQS::Client->new(
$config ? $config->get_aws_access_key_id : undef,
$config ? $config->get_aws_secret_access_key : undef,
{ ServiceURL => $config ? $config->get_aws_endpoint_url : $endpoint_url }
);
$self->set_service($service);
return $self;
}
1;
share/AddPermission.pm view on Meta::CPAN
example.pl [-f config-file] AddPermission label actions account-ids
[queue-url]
'actions' and 'account-ids' should be comma delimited strings.
Note: If you do not set the queue URL in the config, then you must
provide it on the command line.
=head1 OPTIONS
--endpoint-url, -e API endpoint, default: https://queue.amazonaws.com
--file, -f Name of a .ini configuration file help, -h help
=cut
share/DeleteMessage.pm view on Meta::CPAN
=head1 USAGE
example.pl [-f config-file] DeleteMessage receipt-handle [queue-url]
Note: If you do not set the queue URL in the config, then you must
provide it on the command line.
=head1 OPTIONS
--endpoint-url, -e API endpoint, default: https://queue.amazonaws.com
--file, -f Name of a .ini configuration file
--help, -h help
=cut
share/DeleteQueue.pm view on Meta::CPAN
=head1 USAGE
example.pl [-f config-file] DeleteQueue [queue-url]
Note: If you do not set the queue URL in the config, then you must
provide it on the command line.
=head1 OPTIONS
--endpoint-url, -e API endpoint, default: https://queue.amazonaws.com
--file, -f Name of a .ini configuration file
--help, -h help
=cut
share/GetQueueAttributes.pm view on Meta::CPAN
example.pl [-f config-file] GetQueueAttributes attributes [queue-url]
attributes is a list of attributes. Default: 'All'
Note: If you do not set the queue URL in the config, then you must
provide it on the command line.
=head1 OPTIONS
--endpoint-url, -e API endpoint, default: https://queue.amazonaws.com
--file, -f Name of a .ini configuration file help, -h help
=cut
share/ReceiveMessage.pm view on Meta::CPAN
Note: If you do not set the queue URL in the config, then you must
provide it on the command line.
Will return the message and receipt handle. Use the receipt handle to
delete the message.
example.pl -f aws-sqs.ini SendMessage "Hello World!"
=head1 OPTIONS
--endpoint-url, -e API endpoint, default: https://queue.amazonaws.com
--file, -f Name of a .ini configuration file
--help, -h help
=cut
share/RemovePermission.pm view on Meta::CPAN
=head1 USAGE
example.pl [-f config-file] RemovePermission label [queue-url]
Note: If you do not set the queue URL in the config, then you must
provide it on the command line.
=head1 OPTIONS
--endpoint-url, -e API endpoint, default: https://queue.amazonaws.com
--file, -f Name of a .ini configuration file
--help, -h help
=cut
share/SendMessage.pm view on Meta::CPAN
=head1 USAGE
example.pl [-f config-file] SendMessage message [queue-url]
Note: If you do not set the queue URL in the config, then you must
provide it on the command line.
=head1 OPTIONS
--endpoint-url, -e API endpoint, default: https://queue.amazonaws.com
--file, -f Name of a .ini configuration file
--help, -h help
=cut
share/SetQueueAttributes.pm view on Meta::CPAN
attributes is a list of key, value pairs. Example:
'VisibilityTimeout=60,MessageRetentionPeriod=3600'
Note: If you do not set the queue URL in the config, then you must
provide it on the command line.
=head1 OPTIONS
--endpoint-url, -e API endpoint, default: https://queue.amazonaws.com
--file, -f Name of a .ini configuration file help, -h help
=cut
share/example.pl view on Meta::CPAN
use Getopt::Long qw(:config no_ignore_case);
########################################################################
sub main {
########################################################################
my %options;
my @option_specs = qw(
file|f=s
help|h
endpoint-url|e=s
debug|d
);
my $retval = GetOptions( \%options, @option_specs );
if ( !$retval || ( $options{help} && !@ARGV ) ) {
pod2usage(1);
}
my $example = shift @ARGV;
share/example.pl view on Meta::CPAN
=head1 NAME
example.pl
=head1 USAGE
example.pl -f config-name example args
=head1 OPTIONS
--endpoint-url, -e API endpoint, default: https://queue.amazonaws.com
--file, -f Name of a .ini configuration file
--help, -h help
=head2 Configuration File
Some examples may rely on values you must set in your .ini file.
See L<Amazon::SQS::Config> for the format of the .ini file.
=head2 AWS Credentials