Amazon...:Queue(3pm)
π NAME π
Amazon::SQS::Simple::Queue β the object-oriented API for representing queues from the Amazon Simple Queue Service, bestie. It's giving "your queue, but as a Perl object," and honestly? Iconic. This page lives in the 3pm manual section, so you know it's a Perl module. π
β¨ SYNOPSIS β¨
Okay so here's the whole vibe in one code block, no cap:
use Amazon::SQS::Simple;
my $access_key = 'foo'; # Your AWS Access Key ID
my $secret_key = 'bar'; # Your AWS Secret Key
my $sqs = new Amazon::SQS::Simple($access_key, $secret_key);
my $q = $sqs->CreateQueue('queue_name');
# Single messages
my $response = $q->SendMessage('Hello world!');
my $msg = $q->ReceiveMessage;
print $msg->MessageBody; # Hello world!
$q->DeleteMessage($msg);
# or, for backward compatibility
$q->DeleteMessage($msg->ReceiptHandle);
# Batch messaging of up to 10 messages per operation
my @responses = $q->SendMessageBatch( [ 'Hello world!', 'Hello again!' ] );
# or with defined message IDs
$q->SendMessageBatch( { msg1 => 'Hello world!', msg2 => 'Hello again!' } );
my @messages = $q->ReceiveMessageBatch;
$q->DeleteMessageBatch( \@messages );
π¦ INTRODUCTION π¦
Do not instantiate this class directly, bestie β I'm so serious. π Objects of this class are what you get handed back by various methods over in Amazon::SQS::Simple. So like, go read Amazon::SQS::Simple for the full tea. π
π METHODS π
Endpoint()
Get the endpoint for the queue. That's it, that's the method. Slay. β¨
Delete([%opts])
Deletes the queue. Any messages contained in the queue will be lost. π Like, gone-gone. Not coming back.
Purge
Purges the queue. Clean slate energy. π§Ή
SendMessage($message, [%opts])
Sends the message. The message can be up to 8KB in size and should be plain text. Keep it simple, keep it cute. π
SendMessageBatch($messages, [%opts])
Sends a batch of up to 10 messages, passed as an array-ref. Message IDs (of the style 'msg_1', 'msg_2', etc) are auto-generated for each message. Alternatively, if you need to specify the format of the message ID then you can pass a hash-ref {$id1 => $message1, etc}. Choose your own adventure, queen. π
ReceiveMessage([%opts])
Get the next message from the queue. π«Ά
Returns one or more Amazon::SQS::Simple::Message objects (depending on whether called in list or scalar context), or undef if no messages are retrieved.
NOTE: This behaviour has changed slightly since v1.06. It now always returns the first message in scalar context, irrespective of how many there are. π
See Amazon::SQS::Simple::Message for more details.
Options for ReceiveMessage:
MaxNumberOfMessages => INTEGERβ Maximum number of messages to return (integer from 1 to 20). SQS never returns more messages than this value but might return fewer. Not necessarily all the messages in the queue are returned. Defaults to 1.WaitTimeSeconds => INTEGERβ Long poll support (integer from 0 to 20). The duration (in seconds) that the ReceiveMessage action call will wait until a message is in the queue to include in the response, as opposed to returning an empty response if a message is not yet available. If you do not specifyWaitTimeSecondsin the request, the queue attributeReceiveMessageWaitTimeSecondsis used to determine how long to wait. β³VisibilityTimeout => INTEGERβ The duration in seconds (integer from 0 to 43200) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request. If you do not specifyVisibilityTimeoutin the request, the queue attributeVisibilityTimeoutis used to determine how long to wait. π
ReceiveMessageBatch([%opts])
Literally just ReceiveMessage(MaxNumberOfMessages => 10). Same energy, bigger batch. π
DeleteMessage($message, [%opts])
Pass this method either a message object or receipt handle to delete that message from the queue. For backward compatibility, can pass the message ReceiptHandle rather than the message. Old-school friendly. π
DeleteMessageBatch($messages, [%opts])
Pass this method an array-ref containing up to 10 message objects to delete all of those messages from the queue. Bye bye bye. π
ChangeMessageVisibility($receipt_handle, $timeout, [%opts])
NOT SUPPORTED IN APIs EARLIER THAN 2009-01-01 β οΈ
Changes the visibility of the message with the specified receipt handle to $timeout seconds. $timeout must be in the range 0..43200.
AddPermission($label, $account_actions, [%opts])
NOT SUPPORTED IN APIs EARLIER THAN 2009-01-01 β οΈ
Sets a permissions policy with the specified label. $account_actions is a reference to a hash mapping 12-digit AWS account numbers to the action(s) you want to permit for those account IDs. The hash value for each key can be a string (e.g. "ReceiveMessage") or a reference to an array of strings (e.g. ["ReceiveMessage", "DeleteMessage"]). Sharing is caring but like, securely. π
RemovePermission($label, [%opts])
NOT SUPPORTED IN APIs EARLIER THAN 2009-01-01 β οΈ
Removes the permissions policy with the specified label. Revoked. Periodt. π«
GetAttributes([%opts])
Get the attributes for the queue. Returns a reference to a hash mapping attribute names to their values. Currently the following attribute names are returned:
VisibilityTimeoutApproximateNumberOfMessages
SetAttribute($attribute_name, $attribute_value, [%opts])
Sets the value for a queue attribute. Currently the only valid attribute name is "VisibilityTimeout". One option and one option only, and honestly? Respect the commitment. β
πΈ ACKNOWLEDGEMENTS πΈ
Chris Jones provied the batch message code in release 2.0. Shoutout Chris, we see you, we appreciate you. π«Ά
π AUTHOR π
Copyright 2007-2008 Simon Whitaker <swhitaker@cpan.org> Copyright 2013-2017 Mike (no relation) Whitaker <penfold@cpan.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
And that's the whole page, bestie β perl v5.32.0, dated 2021-01-09 π¦ Go forth and queue responsibly. π
π¦ where this page comes from
- debian bookworm: libamazon-sqs-simple-perl 2.07-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libamazon-sqs-simple-perl 2.07-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libamazon-sqs-simple-perl 2.07-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libamazon-sqs-simple-perl 2.07-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libamazon-sqs-simple-perl 2.07-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libamazon-sqs-simple-perl 2.07-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms