NAME
Amazon::SQS::Client - client interface to Amazon Simple Queue Service
SYNOPSIS
# create an HTTP client
my $client = Amazon::SQS::Client->new( $AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY );
# send a message
my $response = $client->sendMessage(
{ QueueUrl => $AWS_QUEUE_URL,
MessageBody => $message
}
);
DESCRIPTION
Amazon::SQS::Client is the implementation of a service API to Amazon's Simple Queue Service.
NOTE: The classes that implement the SQS Perl framework were originally provided by AWS back in the day when Perl was an important part of the AWS development stack. Fast forward to 2024 and Perl is no longer a supported language in the AWS SDK ecosystem. These modules "work" and provide a fairly simple toolset for working with SQS. There are more popular and perhaps more supported packages available for interacting with SQS. See "SEE ALSO" for recommended alternatives. You may however find this implementation lighter in weight than other implementations.
DETAILS
Amazon Simple Queue Service (Amazon SQS) offers a reliable, highly scalable hosted queue for storing messages as they travel between computers.
By using Amazon SQS, developers can simply move data between distributed application components performing different tasks, without losing messages or requiring each component to be always available. Amazon SQS works by exposing Amazon's web-scale messaging infrastructure as a web service. Any computer on the Internet can add or read messages without any installed software or special firewall configurations. Components of applications using Amazon SQS can run independently, and do not need to be on the same network, developed with the same technologies, or running at the same time.
METHODS AND SUBROUTINES
new
new( aws-access-key-id, aws-secret-access-key, [token], [options] )
- aws-access-key-id
-
The AWS access key your were given when you signed up for AWS services.
You can create a new account by visiting "http://aws.amazon.com/".
- aws-secret-access-key
-
The AWS secret access key you were given when you signed up for AWS services.
- token
-
Pass the session token as the third argument on as SecurityToken in the options hash described below.
- options
-
options
is an optional hash reference containing the options listed below.ServiceURL
default:
https://queue.amazonaws.com
Set the ServiceUrl when you want to use a mocking service like LocalStack.
UserAgent
default: LWP::UserAgent
SignatureVersion
default: 2
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.
SecurityToken
For temporary credentials, add the security token returned from the AWS Security Token Service.
ServiceVersion
default: 2012-11-05
MaxErrorRetry
default: 3
credentials
An instance of a class (e.g. Amazon::Credentials) which supports the getters:
get_aws_access_key_id get_aws_secret_access_key get_token
You are encouraged to use this option rather than sending the credentials in the constructor.
createQueue
createQueue( request )
The CreateQueue
action creates a new queue, or returns the URL of an existing one. When you request 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 isn't created and an error isn't returned. Instead, the request succeeds and the queue URL for the existing queue is returned.
Exception: if you provide a value for DefaultVisibilityTimeout
that is different from the value for the existing queue, you receive an error.
Returns an Amazon::SQS::Model::CreateQueueResponse
object.
Throws an Amazon::SQS::Exception
. Use eval to catch it.
- request
-
request
is either a hash reference of parameters for aAmazon::SQS::Model::CreateQueueRequest
object or aAmazon::SQS::Model::CreateQueueRequest
object itself.See
Amazon::SQS::Model::CreateQueueRequest
for valid arguments.
listQueues
listQueues( request )
The ListQueues action returns a list of your queues.
Returns an Amazon::SQS::Model::ListQueuesResponse
object.
Throws an Amazon::SQS::Exception
. Use eval to catch it
- request
-
Argument either hash reference of parameters for
Amazon::SQS::Model::ListQueuesRequest
request orAmazon::SQS::Model::ListQueuesRequest
object itself.See
Amazon::SQS::Model::ListQueuesRequest
for valid arguments.
addPermission
addPermission( )
Adds the specified permission(s) to a queue for the specified principal(s). This allows for sharing access to the queue.
Returns an Amazon::SQS::Model::AddPermissionResponse
.
Throws Amazon::SQS::Exception. Use eval to catch
it.
- request
-
request
is either a hash reference of parameters forAmazon::SQS::Model::AddPermissionRequest
request orAmazon::SQS::Model::AddPermissionRequest
object itself.See
Amazon::SQS::Model::AddPermissionRequest for valid
arguments
changeMessageVisibility
changeMessageVisibility( request )
The ChangeMessageVisibility
action extends the read lock timeout of the specified message from the specified queue to the specified value.
Returns an Amazon::SQS::Model::ChangeMessageVisibilityResponse
Throws an Amazon::SQS::Exception
. Use eval to catch it
- request
-
<request> is either a hash reference of parameters for
Amazon::SQS::Model::ChangeMessageVisibilityRequest
request orAmazon::SQS::Model::ChangeMessageVisibilityRequest
object itself.See
Amazon::SQS::Model::ChangeMessageVisibilityRequest
for valid arguments.
deleteMessage
deleteMessage( request )
The DeleteMessage
action unconditionally removes the specified message from the specified queue. Even if the message is locked by another reader due to the visibility timeout setting, it is still deleted from the queue.
Returns an Amazon::SQS::Model::DeleteMessageResponse
object.
Throws an Amazon::SQS::Exception
. Use eval to catch it.
- request
-
c<request> is either a hash reference of parameters for
Amazon::SQS::Model::DeleteMessageRequest
request orAmazon::SQS::Model::DeleteMessageRequest
object itself.See
Amazon::SQS::Model::DeleteMessageRequest
for valid arguments
deleteQueue
deleteQueue( request )
This action unconditionally deletes the queue specified by the queue URL. Use this operation WITH CARE! The queue is deleted even if it is NOT empty.
Returns an Amazon::SQS::Model::DeleteQueueResponse
Throws an Amazon::SQS::Exception
. Use eval to catch it
- request
-
request
can either be a hash reference of parameters forAmazon::SQS::Model::DeleteQueueRequest
request orAmazon::SQS::Model::DeleteQueueRequest
object itself.See
Amazon::SQS::Model::DeleteQueueRequest
for valid arguments.
getQueueAttributes
getQueueAttributes( request )
Gets one or all attributes of a queue. Queues currently have two attributes you can get: <ApproximateNumberOfMessages> and VisibilityTimeout
.
Returns an Amazon::SQS::Model::GetQueueAttributesResponse
object.
Throws an Amazon::SQS::Exception
. Use eval to catch it.
- request
-
request
can be either a hash reference of parameters forAmazon::SQS::Model::GetQueueAttributesRequest
request orAmazon::SQS::Model::GetQueueAttributesRequest
object itself.See
Amazon::SQS::Model::GetQueueAttributesRequest
for valid arguments.
removePermissions
removePermissions( request )
Removes the permission with the specified statement id from the queue.
Returns an Amazon::SQS::Model::RemovePermissionResponse
object.
Throws an Amazon::SQS::Exception
. Use eval to catch it.
- request
-
request
can be either a hash reference of parameters forAmazon::SQS::Model::RemovePermissionRequest
request orAmazon::SQS::Model::RemovePermissionRequest object
itself.See
Amazon::SQS::Model::RemovePermissionRequest
for valid arguments.
receiveMessage
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 ReceiveMessage
request, it is not returned on subsequent ReceiveMessage
requests for the duration of the VisibilityTimeout
. If you do not specify a VisibilityTimeout
in the request, the overall visibility timeout for the queue is used for the returned messages.
Returns an Amazon::SQS::Model::ReceiveMessageResponse
object.
Throws an Amazon::SQS::Exception
. Use eval to catch it.
- request
-
request
can be either a hash reference of parameters forAmazon::SQS::Model::ReceiveMessageRequest
request orAmazon::SQS::Model::ReceiveMessageRequest
object itself.See
Amazon::SQS::Model::ReceiveMessageRequest
for valid arguments.
sendMessage
sendMessage( )
The SendMessage
action delivers a message to the specified queue.
Returns an Amazon::SQS::Model::SendMessageResponse
Throws an Amazon::SQS::Exception. Use eval to catch
it.
- request
-
request
can be either hash a reference of parameters forAmazon::SQS::Model::SendMessageRequest
request orAmazon::SQS::Model::SendMessageRequest
object itself.See
Amazon::SQS::Model::SendMessageRequest
for valid arguments.
setQueueAttributes
setQueueAttributes( )
Sets an attribute of a queue. Currently, you can set only the VisibilityTimeout
attribute for a queue.
Returns an Amazon::SQS::Model::SetQueueAttributesResponse
object.
Throws an Amazon::SQS::Exception
. Use eval to catch it.
- request
-
request
is hash reference of parameters forAmazon::SQS::Model::SetQueueAttributesRequest
request or anAmazon::SQS::Model::SetQueueAttributesRequest
object itself.See
Amazon::SQS::Model::SetQueueAttributesRequest
for valid arguments.
SEE OTHER
Amazon::SQS::Simple, Amazon::API, Paws
AUTHOR
Elena@AWS
Rob Lauer - <bigfoot@cpan.org>