---
name: "Amazon::SQS::Simple::Queue"
section: "3pm"
platform: "linux"
package: "libamazon-sqs-simple-perl"
version: "2.07-1.1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Amazon::SQS::Simple::Queue"
---

# Amazon::SQS::Simple::Queue(3pm)

OO API for representing queues from the Amazon Simple Queue Service.

## NAME

Amazon::SQS::Simple::Queue - OO API for representing queues from  the Amazon Simple Queue Service.

## SYNOPSIS

```
    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

Don't instantiate this class directly. Objects of this class are returned by various methods in `"Amazon::SQS::Simple"`. See Amazon::SQS::Simple for more details.

## METHODS

- **Endpoint()**

  Get the endpoint for the queue.

- **Delete(\[%opts\])**

  Deletes the queue. Any messages contained in the queue will be lost.

- **Purge**

  Purges the queue.

- **SendMessage($message, \[%opts\])**

  Sends the message. The message can be up to 8KB in size and should be plain text.

- **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}

- **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 specify *WaitTimeSeconds* in the request, the queue attribute *ReceiveMessageWaitTimeSeconds* is 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 specify *VisibilityTimeout* in the request, the queue attribute *VisibilityTimeout* is used to  determine how long to wait.

- **ReceiveMessageBatch(\[%opts\])**

  As ReceiveMessage(MaxNumberOfMessages =\> 10)

- **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.

- **DeleteMessageBatch($messages, \[%opts\])**

  Pass this method an array-ref containing up to 10 message objects to delete all of those messages from the queue

- **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"\])

- **RemovePermission($label, \[%opts\])**

  NOT SUPPORTED IN APIs EARLIER THAN 2009-01-01

  Removes the permissions policy with the specified label.

- **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:

  - •

    VisibilityTimeout

  - •

    ApproximateNumberOfMessages

- **SetAttribute($attribute\_name, $attribute\_value, \[%opts\])**

  Sets the value for a queue attribute. Currently the only valid attribute name is `"VisibilityTimeout"`.

## ACKNOWLEDGEMENTS

Chris Jones provied the batch message code in release 2.0

## 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.
