Info

環境:Max OSX 10.8, Perl5
CPANから「Amazon::SQS::Simple」をインストール
http://search.cpan.org/~penfold/Amazon-SQS-Simple-2.00/lib/Amazon/SQS/Simple.pm

$ sudo perl -MCPAN -e shell 
Password: 
cpan[1]> install Amazon::SQS::Simple

sender 作成

#!/usr/bin/env perl                                                                                                                       
use strict;
use warnings;
use Amazon::SQS::Simple;
my $access_key = "****";
my $secret_key = "****";
my $sqs = new Amazon::SQS::Simple( $access_key, $secret_key );
my $q = $sqs->CreateQueue('sample_flect_queue');
$q->SendMessage('Hello World');
exit 0;

receiver 作成

#!/usr/bin/env perl
use strict;
use warnings;
use Amazon::SQS::Simple;
my $access_key = "****";
my $secret_key = "****";
my $sqs = new Amazon::SQS::Simple( $access_key, $secret_key );
my $q = $sqs->CreateQueue('sample_flect_queue');
my $msg = $q->ReceiveMessage();
print $msg->MessageId() . "\n";
print $msg->MessageBody() . "\n";
$q->DeleteMessage( $msg->ReceiptHandle() );
exit 0;

実行してみる

$ perl sqs_msg_sender.pl
$ perl sqs_msg_receiver.pl
d6c7915c-9f19-4bbd-9ab6-a4c70e600a25
Hello World
$ 

Comments

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS