NAME

Amazon::SQS::QueueHandler - base class for creating SQS message queue handlers

SYNOPSIS

package MyHandler;

use parent qw(Amazon::SQS::QueueHandler);

sub handler {
  my ($self, $message) = @_;
 
  return 1; # delete the message
}

1;

DESCRIPTION

Base class for creating queue handlers that work with the QueueDaemon.pl script. You provide a handler class that processes SQS messages. The QueueDaemon.pl script handles the plumbing.

METHODS AND SUBROUTINES

handler

handler(message)

You provide your own handler message that receives a message to process. The message is the decoded body of the message placed on the SQS queue by some other process. Messages can be sent as plain text, JSON strings or x-www-form-encoded strings.

Generally speaking, by default your handler should return a true value if you want the message deleted and a non-zero value if you want the message to be returned to the queue. There are various options available with the QueueDaemon.pl script that control this behavior however.

change_message_visibility

change_message_visibility(timeout)

Changes the message visibility timeout. You may find that in some circumstances you would like to either extend the time the message remains invisible or you want to shorten the time it becomes available. Use this method when your handler receives the message to alter the visibility of the message to other workers.

NOTES

As a subclass of Amazon::SQS::QueueHandler, your class has access to the methods of its parent. Most notably you might want to use the logger which is an instance of a Log::Log4perl logger.

sub handler {
  my ($self, $message) = @_;

  $self->get_logger->info('...got a message!');
  ...
}

The logging level was set either in your configuration file or on the command line when you invoked the QueueDaemon.pl script.

SEE ALSO

Amazon::SQS::Config

AUTHOR

Rob Lauer - <bigfoot@cpan.org>