view release on metacpan or search on metacpan
bin/create-queue.pl view on Meta::CPAN
my $name = $options->{queue};
my $dlq = $name . 'DLQ';
my $redriveAllowPolicy = { redrivePermission => 'allowAll' };
my @attributes = (
{ Name => 'RedriveAllowPolicy',
Value => JSON->new->encode($redriveAllowPolicy)
},
{ Name => 'VisibilityTimeout',
Value => $options->{'visibility-timeout'},
},
);
local $options->{queue} = $dlq;
return create_queue( $client, $options, @attributes );
}
########################################################################
bin/create-queue.pl view on Meta::CPAN
--receive-message-wait-time_seconds, -w
The length of time, in seconds, for which a ReceiveMessage action
waits for a message to arrive. Valid values: An integer from 0 to 20
(seconds). Default: 0.
--visibility-timeout, -v
The visibility timeout for the queue, in seconds. Valid values: An
integer from 0 to 43,200 (12 hours). Default: 30. For more
information about the visibility timeout, see Visibility Timeout in
the Amazon SQS Developer Guide.
=head2 AUTHOR
Rob Lauer - <bigfoot@cpan.org>
=cut
lib/Amazon/SQS/Client.pm view on Meta::CPAN
sub _convertCreateQueue() {
my ( $self, $request ) = @_;
my $parameters = {};
$parameters->{Action} = 'CreateQueue';
if ( $request->isSetQueueName() ) {
$parameters->{'QueueName'} = $request->getQueueName();
}
if ( $request->isSetDefaultVisibilityTimeout() ) {
$parameters->{'DefaultVisibilityTimeout'} = $request->getDefaultVisibilityTimeout();
}
my $attributecreateQueueRequestList = $request->getAttribute();
for my $attributecreateQueueRequestIndex ( 0 .. $#{$attributecreateQueueRequestList} ) {
my $attributecreateQueueRequest = $attributecreateQueueRequestList->[$attributecreateQueueRequestIndex];
if ( $attributecreateQueueRequest->isSetName() ) {
$parameters->{ 'Attribute.' . ( $attributecreateQueueRequestIndex + 1 ) . '.Name' }
= $attributecreateQueueRequest->getName();
}
lib/Amazon/SQS/Client.pm view on Meta::CPAN
$parameters->{Action} = 'ChangeMessageVisibility';
if ( $request->isSetQueueUrl() ) {
$parameters->{QueueUrl} = $request->getQueueUrl();
}
if ( $request->isSetReceiptHandle() ) {
$parameters->{'ReceiptHandle'} = $request->getReceiptHandle();
}
if ( $request->isSetVisibilityTimeout() ) {
$parameters->{'VisibilityTimeout'} = $request->getVisibilityTimeout();
}
my $attributechangeMessageVisibilityRequestList = $request->getAttribute();
for
my $attributechangeMessageVisibilityRequestIndex ( 0 .. $#{$attributechangeMessageVisibilityRequestList} ) {
my $attributechangeMessageVisibilityRequest
= $attributechangeMessageVisibilityRequestList->[$attributechangeMessageVisibilityRequestIndex];
if ( $attributechangeMessageVisibilityRequest->isSetName() ) {
lib/Amazon/SQS/Client.pm view on Meta::CPAN
$parameters->{ 'ChangeMessageVisibilityBatchRequestEntry.' . ( $batchrequestEntryIndex + 1 ) . '.Id' }
= $batchrequestEntry->getId();
}
if ( $batchrequestEntry->isSetReceiptHandle() ) {
$parameters->{ 'ChangeMessageVisibilityBatchRequestEntry.'
. ( $batchrequestEntryIndex + 1 )
. '.ReceiptHandle' } = $batchrequestEntry->getReceiptHandle();
}
if ( $batchrequestEntry->isSetVisibilityTimeout() ) {
$parameters->{ 'ChangeMessageVisibilityBatchRequestEntry.'
. ( $batchrequestEntryIndex + 1 )
. '.VisibilityTimeout' } = $batchrequestEntry->getVisibilityTimeout();
}
}
}
return $parameters;
}
#
# Convert DeleteMessageRequest to name value pairs
#
lib/Amazon/SQS/Client.pm view on Meta::CPAN
my ( $self, $request ) = @_;
my $parameters = {};
$parameters->{Action} = 'ReceiveMessage';
if ( $request->isSetQueueUrl() ) {
$parameters->{QueueUrl} = $request->getQueueUrl();
}
if ( $request->isSetMaxNumberOfMessages() ) {
$parameters->{MaxNumberOfMessages} = $request->getMaxNumberOfMessages();
}
if ( $request->isSetVisibilityTimeout() ) {
$parameters->{VisibilityTimeout} = $request->getVisibilityTimeout();
}
if ( $request->isSetWaitTimeSeconds() ) {
$parameters->{WaitTimeSeconds} = $request->getWaitTimeSeconds();
}
my $attributeNamereceiveMessageRequestList = $request->getAttributeName();
for my $attributeNamereceiveMessageRequestIndex ( 0 .. $#{$attributeNamereceiveMessageRequestList} ) {
my $attributeNamereceiveMessageRequest
= $attributeNamereceiveMessageRequestList->[$attributeNamereceiveMessageRequestIndex];
lib/Amazon/SQS/Client.pm view on Meta::CPAN
createQueue( request )
The C<CreateQueue> action creates a new queue, or returns the URL of an
existing one. When you request C<CreateQueue>, you provide a name for
the queue. To successfully create a new queue, you must provide a name
that is unique within the scope of your own queues. If you provide the
name of an existing queue, a new queue isnE<039>t created and an error
isnE<039>t returned. Instead, the request succeeds and the queue URL for
the existing queue is returned.
I<Exception: if you provide a value for C<DefaultVisibilityTimeout> that is
different from the value for the existing queue, you receive an error.>
See
L</http://docs.amazonwebservices.com/AWSSimpleQueueService/2009-02-01/SQSDeveloperGuide/Query_QueryCreateQueue.html>.
Returns an C<Amazon::SQS::Model::CreateQueueResponse> object.
Throws an C<Amazon::SQS::Exception>. Use eval to catch it.
=over 5
lib/Amazon/SQS/Client.pm view on Meta::CPAN
See C<Amazon::SQS::Model::DeleteQueueRequest> for valid arguments.
=back
=head2 getQueueAttributes
getQueueAttributes( request )
Gets one or all attributes of a queue. Queues currently have two
attributes you can get: <ApproximateNumberOfMessages> and
C<VisibilityTimeout>.
Returns an C<Amazon::SQS::Model::GetQueueAttributesResponse> object.
Throws an C<Amazon::SQS::Exception>. Use eval to catch it.
See
L</http://docs.amazonwebservices.com/AWSSimpleQueueService/2009-02-01/SQSDeveloperGuide/Query_QueryGetQueueAttributes.html>
=over 5
lib/Amazon/SQS/Client.pm view on Meta::CPAN
receiveMessage( )
Retrieves one or more messages from the specified queue. For each
message returned, the response includes the message body; MD5 digest
of the message body; receipt handle, which is the identifier you must
provide when deleting the message; and message ID of each message.
Messages returned by this action stay in the queue until you
delete them. However, once a message is returned to a C<ReceiveMessage>
request, it is not returned on subsequent C<ReceiveMessage> requests for
the duration of the C<VisibilityTimeout>. If you do not specify a
C<VisibilityTimeout> in the request, the overall visibility timeout for
the queue is used for the returned messages.
Returns an C<Amazon::SQS::Model::ReceiveMessageResponse> object.
Throws an C<Amazon::SQS::Exception>. Use eval to catch it.
See
L</http://docs.amazonwebservices.com/AWSSimpleQueueService/2009-02-01/SQSDeveloperGuide/Query_QueryReceiveMessage.html>
=over 5
lib/Amazon/SQS/Client.pm view on Meta::CPAN
See C<Amazon::SQS::Model::SendMessageRequest> for valid arguments.
=back
=head2 setQueueAttributes
setQueueAttributes( )
Sets an attribute of a queue. Currently, you can set only the
C<VisibilityTimeout> attribute for a queue.
Returns an C<Amazon::SQS::Model::SetQueueAttributesResponse> object.
Throws an C<Amazon::SQS::Exception>. Use eval to catch it.
See
L</http://docs.amazonwebservices.com/AWSSimpleQueueService/2009-02-01/SQSDeveloperGuide/Query_QuerySetQueueAttributes.html>
=over 5
lib/Amazon/SQS/Config.pm view on Meta::CPAN
The name (not the URL) of the queue.
=item url
The queue URL.
=item visibility_timeout
From the AWS documentation:
I<You can provide the VisibilityTimeout parameter in your request. The
parameter is applied to the messages that Amazon SQS returns in the
response. If you don't include the parameter, the overall visibility
timeout for the queue is used for the returned messages. The default
visibility timeout for a queue is 30 seconds.>
default: 30
=item wait_time
The number of seconds to wait for a message (long polling). The
lib/Amazon/SQS/Model/Attribute.pm view on Meta::CPAN
=pod
=head1 NAME
Amazon::SQS::Model::Attribute
=head1 SYNOPSIS
my $attribute = new Amazon::SQS::Model::Attribute(
{
Name => 'VisibilityTimeout',
Value => '60'
}
);
=head1 DESCRIPTION
Create an attribute object for use with various SQS API requests.
=head1 METHODS
lib/Amazon/SQS/Model/ChangeMessageVisibilityBatchRequestEntry.pm view on Meta::CPAN
=head1 NAME
Amazon::SQS::Model::ChangeMessageVisibilityBatchRequestEntry
=head1 SYNOPSIS
my $attribute = new Amazon::SQS::Model::ChangeMessageVisibilityBatchRequestEntry(
{
Id => id,
ReceiptHandle => receiptHandle,
VisibilityTimeout => '60'
}
=cut
sub new {
my ($class, $data) = @_;
my $self = {};
$self->{_fields} = {
Id => { FieldValue => undef, FieldType => "string"},
ReceiptHandle => { FieldValue => undef, FieldType => "string"},
VisibilityTimeout => {FieldValue => undef, FieldType => "int"},
};
bless ($self, $class);
if (defined $data) {
$self->_fromHashRef($data);
}
return $self;
}
lib/Amazon/SQS/Model/ChangeMessageVisibilityBatchRequestEntry.pm view on Meta::CPAN
$self->setId($value);
return $self;
}
sub isSetId {
return defined (shift->{_fields}->{Id}->{FieldValue});
}
sub getVisibilityTimeout {
return shift->{_fields}->{VisibilityTimeout}->{FieldValue};
}
sub setVisibilityTimeout {
my ($self, $value) = @_;
$self->{_fields}->{VisibilityTimeout}->{FieldValue} = $value;
return $self;
}
sub withVisibilityTimeout {
my ($self, $value) = @_;
$self->setVisibilityTimeout($value);
return $self;
}
sub isSetVisibilityTimeout {
return defined (shift->{_fields}->{VisibilityTimeout}->{FieldValue});
}
sub getReceiptHandle {
return shift->{_fields}->{ReceiptHandle}->{FieldValue};
}
sub setReceiptHandle {
my ($self, $value) = @_;
lib/Amazon/SQS/Model/ChangeMessageVisibilityRequest.pm view on Meta::CPAN
#
# Amazon::SQS::Model::ChangeMessageVisibilityRequest
#
# Properties:
#
#
# QueueUrl: string
# ReceiptHandle: string
# VisibilityTimeout: int
# Attribute: Amazon::SQS::Model::Attribute
#
#
#
sub new {
my ($class, $data) = @_;
my $self = {};
$self->{_fields} = {
QueueUrl => { FieldValue => undef, FieldType => "string"},
ReceiptHandle => { FieldValue => undef, FieldType => "string"},
VisibilityTimeout => { FieldValue => undef, FieldType => "int"},
Attribute => {FieldValue => [], FieldType => ["Amazon::SQS::Model::Attribute"]},
};
bless ($self, $class);
if (defined $data) {
$self->_fromHashRef($data);
}
return $self;
}
lib/Amazon/SQS/Model/ChangeMessageVisibilityRequest.pm view on Meta::CPAN
$self->setReceiptHandle($value);
return $self;
}
sub isSetReceiptHandle {
return defined (shift->{_fields}->{ReceiptHandle}->{FieldValue});
}
sub getVisibilityTimeout {
return shift->{_fields}->{VisibilityTimeout}->{FieldValue};
}
sub setVisibilityTimeout {
my ($self, $value) = @_;
$self->{_fields}->{VisibilityTimeout}->{FieldValue} = $value;
return $self;
}
sub withVisibilityTimeout {
my ($self, $value) = @_;
$self->setVisibilityTimeout($value);
return $self;
}
sub isSetVisibilityTimeout {
return defined (shift->{_fields}->{VisibilityTimeout}->{FieldValue});
}
sub getAttribute {
return shift->{_fields}->{Attribute}->{FieldValue};
}
sub setAttribute {
my $self = shift;
foreach my $attribute (@_) {
if (not $self->_isArrayRef($attribute)) {
lib/Amazon/SQS/Model/CreateQueueRequest.pm view on Meta::CPAN
=item options
Hash reference containing the options listed below.
=over 5
=item QueueName
The name of the queue that you created.
=item DefaultVisibilityTimeout
The amount of time (in seconds) that a message received from a queue
will be I<invisible> to other receiving components when they ask to
receive messages.
=item Attribute
C<Amazon::SQS::Model::Attribute>
=back
lib/Amazon/SQS/Model/CreateQueueRequest.pm view on Meta::CPAN
=back
=cut
sub new {
my ($class, $data) = @_;
my $self = {};
$self->{_fields} = {
QueueName => { FieldValue => undef, FieldType => "string"},
DefaultVisibilityTimeout => { FieldValue => undef, FieldType => "int"},
Attribute => {FieldValue => [], FieldType => ["Amazon::SQS::Model::Attribute"]},
};
bless ($self, $class);
if (defined $data) {
$self->_fromHashRef($data);
}
return $self;
}
lib/Amazon/SQS/Model/CreateQueueRequest.pm view on Meta::CPAN
$self->setQueueName($value);
return $self;
}
sub isSetQueueName {
return defined (shift->{_fields}->{QueueName}->{FieldValue});
}
sub getDefaultVisibilityTimeout {
return shift->{_fields}->{DefaultVisibilityTimeout}->{FieldValue};
}
sub setDefaultVisibilityTimeout {
my ($self, $value) = @_;
$self->{_fields}->{DefaultVisibilityTimeout}->{FieldValue} = $value;
return $self;
}
sub withDefaultVisibilityTimeout {
my ($self, $value) = @_;
$self->setDefaultVisibilityTimeout($value);
return $self;
}
sub isSetDefaultVisibilityTimeout {
return defined (shift->{_fields}->{DefaultVisibilityTimeout}->{FieldValue});
}
sub getAttribute {
return shift->{_fields}->{Attribute}->{FieldValue};
}
sub setAttribute {
my $self = shift;
foreach my $attribute (@_) {
if (not $self->_isArrayRef($attribute)) {
lib/Amazon/SQS/Model/ListDeadLetterSourceQueuesRequest.pm view on Meta::CPAN
This is undocumented on AmazonE<039>s documentation page, however this
perl API apparently sends the attributes implying that you might be
able to list all queues that have a prefix of "some-prefix" AND have
some attribute.
Queue attributes are set when the queue is created and are listed below.
=over 5
=item * VisibilityTimeout
The length of time (in seconds) that a message
received from a queue will be invisible to other receiving components
when they ask to receive messages. For more information about
VisibilityTimeout, see Visibility Timeout in the Amazon SQS Developer
Guide.
=item * Policy
The formal description of the permissions for a resource. For more
information about Policy, see Basic Policy Structure in the Amazon SQS
Developer Guide.
=item * MaximumMessageSize
lib/Amazon/SQS/Model/ListQueuesRequest.pm view on Meta::CPAN
This is undocumented on AmazonE<039>s documentation page, however this
perl API apparently sends the attributes implying that you might be
able to list all queues that have a prefix of "some-prefix" AND have
some attribute.
Queue attributes are set when the queue is created and are listed below.
=over 5
=item * VisibilityTimeout
The length of time (in seconds) that a message
received from a queue will be invisible to other receiving components
when they ask to receive messages. For more information about
VisibilityTimeout, see Visibility Timeout in the Amazon SQS Developer
Guide.
=item * Policy
The formal description of the permissions for a resource. For more
information about Policy, see Basic Policy Structure in the Amazon SQS
Developer Guide.
=item * MaximumMessageSize
lib/Amazon/SQS/Model/MessageAttribute.pm view on Meta::CPAN
=pod
=head1 NAME
Amazon::SQS::Model::Attribute
=head1 SYNOPSIS
my $attribute = new Amazon::SQS::Model::Attribute(
{
Name => 'VisibilityTimeout',
Value => '60'
}
);
=head1 DESCRIPTION
Create an attribute object for use with various SQS API requests.
=head1 METHODS
lib/Amazon/SQS/Model/ReceiveMessageRequest.pm view on Meta::CPAN
#
# Amazon::SQS::Model::ReceiveMessageRequest
#
# Properties:
#
#
# QueueUrl: string
# MaxNumberOfMessages: int
# WaitTimeSeconds: int
# VisibilityTimeout: int
# AttributeName: string
# MessageAttributeName: ["string"]
# ReceiveRequestAttemptId: "string"
#
#
sub new {
my ( $class, $data ) = @_;
my %fields = (
_fields => {
QueueUrl => { FieldValue => undef, FieldType => 'string' },
MaxNumberOfMessages => { FieldValue => undef, FieldType => 'int' },
WaitTimeSeconds => { FieldValue => undef, FieldType => 'int' },
VisibilityTimeout => { FieldValue => undef, FieldType => 'int' },
AttributeName => { FieldValue => [], FieldType => ['string'] },
MessageAttributeName => { FieldValue => [], FieldType => ['string'] },
ReceiveRequestAttemptId => { FieldValue => undef, FieldType => 'string' },
}
);
my $self = bless \%fields, $class;
if ( defined $data ) {
$self->_fromHashRef($data);
lib/Amazon/SQS/Model/ReceiveMessageRequest.pm view on Meta::CPAN
sub withMaxNumberOfMessages {
my ( $self, $value ) = @_;
$self->setMaxNumberOfMessages($value);
return $self;
}
sub isSetMaxNumberOfMessages {
return defined( shift->{_fields}->{MaxNumberOfMessages}->{FieldValue} );
}
sub getVisibilityTimeout {
return shift->{_fields}->{VisibilityTimeout}->{FieldValue};
}
sub setVisibilityTimeout {
my ( $self, $value ) = @_;
$self->{_fields}->{VisibilityTimeout}->{FieldValue} = $value;
return $self;
}
sub withVisibilityTimeout {
my ( $self, $value ) = @_;
$self->setVisibilityTimeout($value);
return $self;
}
sub isSetVisibilityTimeout {
return defined( shift->{_fields}->{VisibilityTimeout}->{FieldValue} );
}
sub getAttributeName {
return shift->{_fields}->{AttributeName}->{FieldValue};
}
sub setAttributeName {
my ( $self, $value ) = @_;
$self->{_fields}->{AttributeName}->{FieldValue} = $value;
return $self;
lib/Amazon/SQS/QueueHandler.pm view on Meta::CPAN
return $self->get_request
if $self->get_request;
my $max_messages = max( 1, $self->get_max_messages ); # max of 1 currently
my $wait_time = $self->get_wait_time // 0;
my $visibility_timeout = $self->get_visibility_timeout;
my $request = Amazon::SQS::Model::ReceiveMessageRequest->new(
{ QueueUrl => $self->get_url,
MaxNumberOfMessages => $max_messages,
VisibilityTimeout => $visibility_timeout,
WaitTimeSeconds => $wait_time,
}
);
$self->set_request($request);
return;
}
########################################################################
sub change_message_visibility {
########################################################################
my ( $self, $timeout ) = @_;
my $service = $self->get_service;
$service->changeMessageVisibility(
QueueUrl => $self->get_url,
ReceiptHandle => $self->get_receipt_handle,
VisibilityTimeout => $timeout,
);
return;
}
########################################################################
sub delete_message {
########################################################################
my ( $self, $handle ) = @_;
share/SetQueueAttributes.pm view on Meta::CPAN
__END__
=pod
=head1 USAGE
example.pl [-f config-file] SetQueueAttributes attributes [queue-url]
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