izing the messages that come from the
queue, SQS::Worker provides you with ways to easily consume JSON messages, for example.
It comes in the form of a Moose role that is to be composed into the end
with the message
}
Composing automatic json decoding to perl data structure
package YourWorker;
use Moose;
with 'SQS::Worker', 'SQS::Worker::DecodeJson';
sub process_message {
my ($self, $
processed a message for $name");
}
=head1 Bundled roles
L<SQS::Worker::DecodeJson> decodes the message body in json format and passes
L<SQS::Worker::DecodeStorable> decodes the message body in P
package SQS::Worker::Client {
use Moose;
use Paws;
use JSON::MaybeXS;
use MIME::Base64;
use Storable qw/nfreeze/;
has queue_url => (is => 'ro', isa => 'Str', required => 1);
has region
o', isa => 'Str', default => 'json');
has _serializer => (is => 'ro', isa => 'HashRef[CodeRef]', default => sub {
return {
json => sub { return encode_json \@_; },
storable => su
use SNS::Notification;
use JSON::MaybeXS;
around process_message => sub {
my ($orig, $self, $message) = @_;
my $body;
eval {
$body = decode_json($message->Body)
};
if
($@) {
$self->log->error("Worker::SNS Error decoding JSON body in message " . $message->ReceiptHandle . ": " . $@ . " for content " . $message->Body);
die $@;
} else {
die "SNS
:Worker::DecodeJson;
use Moose::Role;
use JSON::MaybeXS;
around process_message => sub {
my ($orig, $self, $message) = @_;
my $body;
eval {
$body = decode_json($message->Bod
y)
};
if ($@) {
$self->log->error("Error decoding JSON body in message " . $message->ReceiptHandle . ": " . $@ . " for content " . $message->Body);
die $@;
} else {
if (r