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
-
optionsis an optional hash reference containing the options listed below.ServiceURL
default:
https://queue.amazonaws.comSet 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_tokenYou 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
-
requestis either a hash reference of parameters for aAmazon::SQS::Model::CreateQueueRequestobject or aAmazon::SQS::Model::CreateQueueRequestobject itself.See
Amazon::SQS::Model::CreateQueueRequestfor 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::ListQueuesRequestrequest orAmazon::SQS::Model::ListQueuesRequestobject itself.See
Amazon::SQS::Model::ListQueuesRequestfor 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
-
requestis either a hash reference of parameters forAmazon::SQS::Model::AddPermissionRequestrequest orAmazon::SQS::Model::AddPermissionRequestobject itself.See
Amazon::SQS::Model::AddPermissionRequest for validarguments
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::ChangeMessageVisibilityRequestrequest orAmazon::SQS::Model::ChangeMessageVisibilityRequestobject itself.See
Amazon::SQS::Model::ChangeMessageVisibilityRequestfor 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::DeleteMessageRequestrequest orAmazon::SQS::Model::DeleteMessageRequestobject itself.See
Amazon::SQS::Model::DeleteMessageRequestfor 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
-
requestcan either be a hash reference of parameters forAmazon::SQS::Model::DeleteQueueRequestrequest orAmazon::SQS::Model::DeleteQueueRequestobject itself.See
Amazon::SQS::Model::DeleteQueueRequestfor 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
-
requestcan be either a hash reference of parameters forAmazon::SQS::Model::GetQueueAttributesRequestrequest orAmazon::SQS::Model::GetQueueAttributesRequestobject itself.See
Amazon::SQS::Model::GetQueueAttributesRequestfor 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
-
requestcan be either a hash reference of parameters forAmazon::SQS::Model::RemovePermissionRequestrequest orAmazon::SQS::Model::RemovePermissionRequest objectitself.See
Amazon::SQS::Model::RemovePermissionRequestfor 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
-
requestcan be either a hash reference of parameters forAmazon::SQS::Model::ReceiveMessageRequestrequest orAmazon::SQS::Model::ReceiveMessageRequestobject itself.See
Amazon::SQS::Model::ReceiveMessageRequestfor 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
-
requestcan be either hash a reference of parameters forAmazon::SQS::Model::SendMessageRequestrequest orAmazon::SQS::Model::SendMessageRequestobject itself.See
Amazon::SQS::Model::SendMessageRequestfor 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
-
requestis hash reference of parameters forAmazon::SQS::Model::SetQueueAttributesRequestrequest or anAmazon::SQS::Model::SetQueueAttributesRequestobject itself.See
Amazon::SQS::Model::SetQueueAttributesRequestfor valid arguments.
SEE OTHER
Amazon::SQS::Simple, Amazon::API, Paws
AUTHOR
Elena@AWS
Rob Lauer - <bigfoot@cpan.org>