Lines 49-58
The different values available are:
Link Here
|
49 |
|
49 |
|
50 |
use Modern::Perl; |
50 |
use Modern::Perl; |
51 |
use JSON qw( decode_json ); |
51 |
use JSON qw( decode_json ); |
52 |
use Try::Tiny qw( catch try ); |
52 |
use Try::Tiny; |
53 |
use Pod::Usage; |
53 |
use Pod::Usage; |
54 |
use Getopt::Long; |
54 |
use Getopt::Long; |
55 |
|
55 |
|
|
|
56 |
use Koha::Logger; |
56 |
use Koha::BackgroundJobs; |
57 |
use Koha::BackgroundJobs; |
57 |
|
58 |
|
58 |
my ( $help, @queues ); |
59 |
my ( $help, @queues ); |
Lines 93-107
while (1) {
Link Here
|
93 |
next; # will reconnect automatically |
94 |
next; # will reconnect automatically |
94 |
} |
95 |
} |
95 |
|
96 |
|
96 |
my $body = $frame->body; |
97 |
my $job; |
97 |
my $args = decode_json($body); # TODO Should this be from_json? Check utf8 flag. |
98 |
try { |
98 |
|
99 |
my $body = $frame->body; |
99 |
# FIXME This means we need to have create the DB entry before |
100 |
my $args = decode_json($body); # TODO Should this be from_json? Check utf8 flag. |
100 |
# It could work in a first step, but then we will want to handle job that will be created from the message received |
101 |
|
101 |
my $job = Koha::BackgroundJobs->find($args->{job_id}); |
102 |
# FIXME This means we need to have create the DB entry before |
102 |
|
103 |
# It could work in a first step, but then we will want to handle job that will be created from the message received |
103 |
$conn->ack( { frame => $frame } ); # Acknowledge the message was recieved |
104 |
$job = Koha::BackgroundJobs->find($args->{job_id}); |
104 |
process_job( $job, $args ); |
105 |
|
|
|
106 |
process_job( $job, $args ); |
107 |
} catch { |
108 |
Koha::Logger->get->warn(sprintf "Job and/or frame not processed - %s", $_); |
109 |
} finally { |
110 |
$job->status('failed')->store if $job && @_; |
111 |
$conn->ack( { frame => $frame } ); |
112 |
}; |
105 |
|
113 |
|
106 |
} else { |
114 |
} else { |
107 |
my $jobs = Koha::BackgroundJobs->search({ status => 'new', queue => \@queues }); |
115 |
my $jobs = Koha::BackgroundJobs->search({ status => 'new', queue => \@queues }); |
108 |
- |
|
|