From 061b8d88ec9696b9627018e4c4bca1c8a27f79e4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 24 Mar 2022 16:24:06 +0100 Subject: [PATCH] Bug 30172: Enqueue the job even if rabbitmq is not reachable Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi (cherry picked from commit ce24a745c30f807587857e2f9449176ad4f78291) Signed-off-by: Andrew Fuerste-Henry (cherry picked from commit 25c3a72725009d55c7cfd3078d8cd2a37cf9a071) Signed-off-by: Victor Grousset/tuxayo --- Koha/BackgroundJob.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index 9fb3f37430..ff64fd06f3 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -101,6 +101,7 @@ sub enqueue { my $borrowernumber = C4::Context->userenv->{number}; # FIXME Handle non GUI calls my $json_args = encode_json $job_args; + $self->set( { status => 'new', @@ -113,10 +114,17 @@ sub enqueue { )->store; $job_args->{job_id} = $self->id; - $json_args = encode_json $job_args; + my $conn; + try { + $conn = $self->connect; + } catch { + warn "Cannot connect to broker " . $_; + }; + return unless $conn; + + $json_args = encode_json $job_args; try { - my $conn = $self->connect; # This namespace is wrong, it must be a vhost instead. # But to do so it needs to be created on the server => much more work when a new Koha instance is created. # Also, here we just want the Koha instance's name, but it's not in the config... -- 2.39.5