Amazon::SQS::Simple::AnyEvent - A non-blocking API to Amazon's SQS


  use Amazon::SQS::Simple;
  use Amazon::SQS::Simple::AnyEvent;

  my $sqs = Amazon::SQS::Simple->new($access_key, $secret_key);
  my $queue = $sqs->GetQueue($endpoint);

  my $cb = sub {my $message = shift};

  my $msg   = $queue->ReceiveMessage();     # Blocking
  my $guard = $queue->ReceiveMessage($cb);  # Non-blocking

  # do something else...


This module adds non-blocking capbilities to Amazon::SQS::Simple via AnyEvent. It works by hijacking and replacing methods inside the Amazon::SQS::Simple namespace. However, this could easily break if the internals of Amazon::SQS::Simple change. Also, this code is alpha quality with no automated tests. You have been warned.


The following methods on Amazon::SQS::Simple::Queue are enhanced with non-blocking capabiliites. In all cases, adding a subroutine reference as the last argument will cause the method to be called in non-blocking mode. But instead of returning the results at the method call site, they will be passed to your callback. If the request fails, your callback will receive undef and you can inspect the variable $Amazon::SQS::Simple::AnyEvent::ERROR for a description of the last error. At the method call site, you will receive a guard object for the request. Otherwise, the calling interfaces are exactly the same as those described in Amazon::SQS::Simple::Queue. If you do not pass a callback argument, then the call is sent straight to the original blocking method in Amazon::SQS::Simple.

SendMessage($message, [%opts], [sub{...}])
SendMessageBatch($messages, [%opts], [sub{...}])
ReceiveMessage([%opts], [sub{...}])
ReceiveMessageBatch([%opts], [sub{...}])
DeleteMessage($message, [%opts], [sub{...}])
DeleteMessageBatch($messages, [%opts], [sub{...}])


Jeffrey Ryan Thalhammer <>

Mike Whitaker <>

Simon Whitaker <>


This module was commissioned by Ultrabuys LLC. Ultrabuys is proud to support Perl and the open source community.


This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Copyright (c) 2015 by Jeffrey Ryan Thalhammer