diff --git a/misc/workers/background_jobs_worker.pl b/misc/workers/background_jobs_worker.pl index 81e980998d..afb5f603e5 100755 --- a/misc/workers/background_jobs_worker.pl +++ b/misc/workers/background_jobs_worker.pl @@ -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); diff --git a/misc/workers/es_indexer_daemon.pl b/misc/workers/es_indexer_daemon.pl index 42fb24d6a8..9b69fb59f7 100755 --- a/misc/workers/es_indexer_daemon.pl +++ b/misc/workers/es_indexer_daemon.pl @@ -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) {