Bug 34070: Display the 'jobs will be processed anyway' message from worker

->connect does not raise an exception, so we didn't reached the catch
block.

Adjusting the code but I am not really happy with it, but more changes
will derail the original bug

Now we log:
Cannot connect to broker (Access refused for user 'guest') at /kohadevbox/koha/Koha/BackgroundJob.pm line 96.
Cannot connect to the message broker, the jobs will be processed anyway at /kohadevbox/koha/misc/workers/background_jobs_worker.pl line 100.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 8dfb19a45a)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Jonathan Druart 2025-03-12 16:20:00 +01:00 committed by Fridolin Somers
parent 12b5981e3b
commit bc6548c5e1
No known key found for this signature in database
GPG Key ID: 9A8E73E2A8B96537
1 changed files with 4 additions and 2 deletions

View File

@ -90,12 +90,14 @@ unless (@queues) {
push @queues, 'default';
}
my $conn;
my ( $conn, $error );
try {
$conn = Koha::BackgroundJob->connect;
} catch {
warn sprintf "Cannot connect to the message broker, the jobs will be processed anyway (%s)", $_;
$error = sprintf "Cannot connect to the message broker, the jobs will be processed anyway (%s)", $_;
};
$error ||= "Cannot connect to the message broker, the jobs will be processed anyway" unless $conn;
warn $error if $error;
my $pm = Parallel::ForkManager->new($max_processes);