AWS-SQS-Simple
view release on metacpan or search on metacpan
lib/AWS/SQS/Simple.pm view on Meta::CPAN
Version 0.02
=cut
our $VERSION = '0.02';
=head1 SYNOPSIS
This module is used to access amazon simple queue services.
use AWS::SQS::Simple ;
my $ob = AWS::SQS::Simple->new(
ACCESS_KEY => '..' ,
SECRET_ACCESS_KEY => '..' ,
AWS_ACCOUNT_ID => '..' ,
END_POINT => '..' ,
);
my %params_hash = (
QUEUE_NAME => QUEUE Name ,
'AttributeName.1.Name' => Attribute Name ,
'AttributeName.1.Value' => Attribute Value , [ Required if there is a corresponding Name Attribute.n.name parameter ]
'AttributeName.2.Name' => Attribute Name ,
'AttributeName.2.Value' => Attribute Value , [ Required if there is a corresponding Name Attribute.n.name parameter ]
.....
);
$ob->create_queue( \%params_hash ) ;
my %params_hash = (
QUEUE_NAME => QUEUE Name ,
'MessageBody' => Message to send ,
'DelaySeconds' => The number of seconds to delay a specific message , [ OPTIONAL ]
);
$ob->send_message( \%params_hash ) ;
my %params_hash = (
QUEUE_NAME => QUEUE Name ,
'AttributeName.n' => The attribute you want to get. Valid values: All | SenderId | SentTimestamp | ApproximateReceiveCount | ApproximateFirstReceiveTimestamp , [ OPTIONAL ]
'MaxNumberOfMessages' => Maximum number of messages to return. Default - 1 , [ OPTIONAL ]
'VisibilityTimeout' => The duration in seconds that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request. Default - The visibility timeout for the queue , [ OPTIONAL ]
'WaitTimeSeconds' => Long poll support (integer from 1 to 20 , [ OPTIONAL ]
);
$ob->receive_message->( \%params_hash )
=head1 CONSTRUCTOR
=head2 new
Constructs a new AWS::SQS::Simple object
Following are the parametes taken by the constructor
my $ob = AWS::SQS::Simple->new(
ACCESS_KEY => '..' ,
SECRET_ACCESS_KEY => '..' ,
AWS_ACCOUNT_ID => '..' ,
END_POINT => '..' ,
);
=cut
sub new {
my $class = shift;
my %parameter_hash;
my $count = @_;
my $usage_howto = "
Usage:
my \$ob = AWS::SQS::Simple->new(
ACCESS_KEY => '..' ,
SECRET_ACCESS_KEY => '..' ,
AWS_ACCOUNT_ID => '..' ,
END_POINT => '..' ,
);
";
%parameter_hash = @_;
croak $usage_howto unless( $parameter_hash{ AWS_ACCOUNT_ID } ) ;
croak $usage_howto unless( $parameter_hash{ ACCESS_KEY } ) ;
croak $usage_howto unless( $parameter_hash{ SECRET_ACCESS_KEY } ) ;
croak $usage_howto unless( $parameter_hash{ END_POINT } ) ;
lib/AWS/SQS/Simple.pm view on Meta::CPAN
Usage :
my %params_hash = (
QUEUE_NAME => QUEUE Name ,
'MessageBody' => Message to send ,
'DelaySeconds' => The number of seconds to delay a specific message , [ OPTIONAL ]
);
$ob->send_message->( \%params_hash )
=cut
sub send_message {
my $self = shift ;
my $params = shift ;
my $message_body = $params->{ MessageBody } ;
unless( defined $message_body ){
print STDERR "Error : Message Body not defined" ;
return 0 ;
}
my $params_to_pass = {
'Action' => 'SendMessage' ,
'AWSAccessKeyId' => $self->{ ACCESS_KEY } ,
'Timestamp' => _generate_timestamp() ,
'SignatureVersion' => 2 ,
'Version' => '2009-02-01' ,
'SignatureMethod' => 'HmacSHA256' ,
%{ $params }
};
my $url = $self->_get_url( $params_to_pass ) ;
my $response = $self->_make_request( $url ) ;
return $response ;
}
=head2 receive_message
This function returns mesaages already in the queue specified.
Usage :
my %params_hash = (
QUEUE_NAME => QUEUE Name ,
'AttributeName.n' => The attribute you want to get. Valid values: All | SenderId | SentTimestamp | ApproximateReceiveCount | ApproximateFirstReceiveTimestamp , [ OPTIONAL ]
'MaxNumberOfMessages' => Maximum number of messages to return. Default - 1 , [ OPTIONAL ]
'VisibilityTimeout' => The duration in seconds that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request. Default - The visibility timeout for the queue , [ OPTIONAL ]
'WaitTimeSeconds' => Long poll support (integer from 1 to 20 , [ OPTIONAL ]
);
$ob->receive_message->( \%params_hash )
=cut
sub receive_message {
my $self = shift ;
my $params = shift ;
my $params_to_pass = {
'Action' => 'ReceiveMessage' ,
'AWSAccessKeyId' => $self->{ ACCESS_KEY } ,
'Timestamp' => _generate_timestamp() ,
'SignatureVersion' => 2 ,
'Version' => '2009-02-01' ,
'SignatureMethod' => 'HmacSHA256' ,
%{ $params }
};
my $url = $self->_get_url( $params_to_pass ) ;
my $response = $self->_make_request( $url ) ;
return $response ;
}
=head2 delete_message
This function deletes a message from the queue.
Usage :
my %params_hash = (
QUEUE_NAME => QUEUE Name ,
'ReceiptHandle' => The receipt handle associated with the message you want to delete ,
);
$ob->delete_message->( \%params_hash )
=cut
sub delete_message {
my $self = shift ;
my $params = shift ;
my $receipt_handle = $params->{ ReceiptHandle } ;
unless( defined $receipt_handle ){
print STDERR "Error : Receipt Handle not defined" ;
return 0 ;
}
( run in 0.526 second using v1.01-cache-2.11-cpan-a5abf4f5562 )