From ed20ff6b58f1bd5d6c953c03944330e002c685fc Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 22 Dec 2022 22:17:04 +0000 Subject: [PATCH] Bug 32481: Limit prefetch size for background jobs worker This patch adds a prefetch size of 1 to the background jobs worker, so that it fetches 1 message at a time. Without this change, the RabbitMQ connection timeout when too many messages for slow tasks are fetched at the same time. To test: 0. Apply patch 1. Run background worker 2. Rapidly enqueue multiple jobs that in total will take longer than 30 minutes to process --- misc/background_jobs_worker.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/misc/background_jobs_worker.pl b/misc/background_jobs_worker.pl index eb36f34f96..2a1baee151 100755 --- a/misc/background_jobs_worker.pl +++ b/misc/background_jobs_worker.pl @@ -78,7 +78,11 @@ if ( $conn ) { # FIXME cf note in Koha::BackgroundJob about $namespace my $namespace = C4::Context->config('memcached_namespace'); for my $queue (@queues) { - $conn->subscribe({ destination => sprintf("/queue/%s-%s", $namespace, $queue), ack => 'client' }); + $conn->subscribe({ + destination => sprintf("/queue/%s-%s", $namespace, $queue), + ack => 'client', + 'activemq.prefetchSize' => 1, + }); } } while (1) { -- 2.30.2