Amazon-SQS-Simple

 view release on metacpan or  search on metacpan

lib/Amazon/SQS/Simple/Queue.pm  view on Meta::CPAN

    $params{'Attribute.Name'}   = $key;
    $params{'Attribute.Value'}  = $value;
    
    my $href = $self->_dispatch(\%params);
}

sub _to_string {
    my $self = shift;
    return $self->Endpoint();
}

1;

__END__

=head1 NAME

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

=head1 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 );

=head1 INTRODUCTION

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

=head1 METHODS

=over 2

=item B<Endpoint()>

Get the endpoint for the queue.

=item B<Delete([%opts])>
 
Deletes the queue. Any messages contained in the queue will be lost.

=item B<Purge>

Purges the queue.

=item B<SendMessage($message, [%opts])>

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

=item B<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}

=item B<ReceiveMessage([%opts])>

Get the next message from the queue.

Returns one or more C<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 L<Amazon::SQS::Simple::Message> for more details.

Options for ReceiveMessage:

=over 4

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

=item * WaitTimeSeconds => INTEGER

Long poll support (integer from 0 to 20). The duration (in seconds) that the I<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 I<WaitTimeSeconds> in the request, the queue attribute I<ReceiveMessageWaitTimeSeconds>
is used to determine how long to wait.

=item * 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 I<ReceiveMessage> request.

If you do not specify I<VisibilityTimeout> in the request, the queue attribute I<VisibilityTimeout> is used to 
determine how long to wait.

=back



( run in 2.587 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )