Bug 34070: Deal with broker connection issues

This patch suggests to deal with connection issues at
Koha::BackgroundJob->connect level.
It incorrectly returned a Net::Stomp object when the connection failed.
With this patch, if the CONNECT does not return a CONNECTED frame then
Koha::BackgroundJob->connect returns nothing and the caller is not
fooled.

It also fixes the about page, we now have:
 "Using SQL polling (Fallback, Error connecting to RabbitMQ)"
instead of
 "Using RabbitMQ"

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 c407ce021e)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Jonathan Druart 2025-03-10 10:54:25 +01:00 committed by Fridolin Somers
parent ad35b19273
commit e8de06a0de
No known key found for this signature in database
GPG Key ID: 9A8E73E2A8B96537
1 changed files with 9 additions and 3 deletions

View File

@ -89,10 +89,16 @@ sub connect {
try {
$stomp = Net::Stomp->new( { hostname => $hostname, port => $port } );
$stomp->connect( $credentials );
my $connected_frame = $stomp->connect($credentials);
if ( $connected_frame->command ne 'CONNECTED' ) {
my $message = $connected_frame->body;
chomp $message;
warn sprintf "Cannot connect to broker (%s)", $message;
undef $stomp;
}
} catch {
warn "Cannot connect to broker " . $_;
$stomp = undef;
warn sprintf "Cannot connect to broker (%s)", $_;
undef $stomp;
};
return $stomp;