Bug 40820: Fix STOMP connection warnings when JobsNotificationMethod is 'polling'
The background job workers are showing STOMP/RabbitMQ connection error
warnings even when the JobsNotificationMethod system preference was set
to 'polling', which doesn't require a message broker connection.
This patch adds checks for the JobsNotificationMethod preference before
displaying connection warnings, so warnings only appear when STOMP is
actually expected to be available.
Changes:
- misc/workers/background_jobs_worker.pl: Check syspref before warning
- misc/workers/es_indexer_daemon.pl: Check syspref before warning
Test plan:
1. Set JobsNotificationMethod to 'polling'
2. Run background_jobs_worker.pl - should not show STOMP warnings
3. Run es_indexer_daemon.pl - should not show STOMP warnings
4. Set JobsNotificationMethod to 'STOMP' without RabbitMQ running
5. Run workers - should show appropriate STOMP connection warnings
6. Sign off :-D
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4ff1f4ca9c)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
4cd910b176
commit
c9f4566aa6
|
|
@ -90,14 +90,18 @@ unless (@queues) {
|
|||
push @queues, 'default';
|
||||
}
|
||||
|
||||
my $notification_method = C4::Context->preference('JobsNotificationMethod') // 'STOMP';
|
||||
|
||||
my ( $conn, $error );
|
||||
try {
|
||||
$conn = Koha::BackgroundJob->connect;
|
||||
} catch {
|
||||
$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;
|
||||
if ( $notification_method eq 'STOMP' ) {
|
||||
try {
|
||||
$conn = Koha::BackgroundJob->connect;
|
||||
} catch {
|
||||
$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);
|
||||
|
||||
|
|
|
|||
|
|
@ -81,12 +81,16 @@ warn "Not using Elasticsearch" unless C4::Context->preference('SearchEngine') eq
|
|||
|
||||
my $logger = Koha::Logger->get( { interface => 'worker' } );
|
||||
|
||||
my $notification_method = C4::Context->preference('JobsNotificationMethod') // 'STOMP';
|
||||
|
||||
my $conn;
|
||||
try {
|
||||
$conn = Koha::BackgroundJob->connect;
|
||||
} catch {
|
||||
warn sprintf "Cannot connect to the message broker, the jobs will be processed anyway (%s)", $_;
|
||||
};
|
||||
if ( $notification_method eq 'STOMP' ) {
|
||||
try {
|
||||
$conn = Koha::BackgroundJob->connect;
|
||||
} catch {
|
||||
warn sprintf "Cannot connect to the message broker, the jobs will be processed anyway (%s)", $_;
|
||||
};
|
||||
}
|
||||
|
||||
if ($conn) {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue