From e8de06a0dea2a79b1ea8953cfbde27fb3286f775 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 10 Mar 2025 10:54:25 +0100 Subject: [PATCH] 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 Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer (cherry picked from commit c407ce021e84127a6ca93e8d4c6c2348ace5a93a) Signed-off-by: Fridolin Somers --- Koha/BackgroundJob.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index e395ca6a6c..c33ac827e6 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -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;