Bug 30172: Enqueue the job even if rabbitmq is not reachable
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 24 Mar 2022 15:24:06 +0000 (16:24 +0100)
committerFridolin Somers <fridolin.somers@biblibre.com>
Mon, 4 Apr 2022 14:23:46 +0000 (16:23 +0200)
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Koha/BackgroundJob.pm

index 2bb6f49..b8c0109 100644 (file)
@@ -100,6 +100,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',
@@ -112,10 +113,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...