File Coverage

blib/lib/SQS/Consumers/DeleteAlways.pm
Criterion Covered Total %
statement 21 21 100.0
branch 2 2 100.0
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 26 27 96.3


line stmt bran cond sub pod time code
1             package SQS::Consumers::DeleteAlways;
2 8     8   48 use Moose;
  8         16  
  8         44  
3 8     8   46907 use namespace::autoclean;
  8         22  
  8         51  
4              
5             sub fetch_message {
6 6     6 0 15 my $self = shift;
7 6         12 my $worker = shift;
8              
9 6         126 $worker->log->debug('Receiving Messages');
10 6         291 my $message_pack = $worker->receive_message();
11              
12 6         138 $worker->log->debug(sprintf "Got %d messages", scalar(@{ $message_pack->Messages }));
  6         39  
13              
14 6         393 foreach my $message (@{$message_pack->Messages}) {
  6         21  
15 6         294 $worker->log->info("Processing message " . $message->ReceiptHandle);
16             # We have to delete the message from the queue in any case, but we don't
17             # want to wait for the process to finish (if the process is longer than
18             # the messages visibility timeout, then the message will possibly be redelivered
19 6         240 $worker->delete_message($message);
20              
21 6         201 eval {
22 6         15 $worker->process_message($message);
23             };
24 6 100       273 if ($@) {
25 3         78 $worker->log->error("Exception caught: " . $@);
26 3         189 $worker->on_failure->($worker, $message);
27             }
28             }
29             }
30              
31             __PACKAGE__->meta->make_immutable;
32             1;