From 6ad068c61e6b1090eae94cf018ee24206f8d6017 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 20 Feb 2020 16:39:13 +0100 Subject: [PATCH] Bug 22417: Restore the concept of namespace Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Cook --- Koha/BackgroundJob.pm | 7 ++++++- misc/background_jobs_worker.pl | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index b905f09b8a..e53fd37dba 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -50,7 +50,12 @@ sub enqueue { $json_args = encode_json $job_args; my $conn = $self->connect; - $conn->send_with_receipt( { destination => $job_type, body => $json_args } ) + # This namespace is wrong, it must be a vhost instead. + # But to do so it needs to be created on the server => much more work when a new Koha instance is created. + # Also, here we just want the Koha instance's name, but it's not in the config... + # Picking a random id (memcached_namespace) from the config + my $namespace = C4::Context->config('memcached_namespace'); + $conn->send_with_receipt( { destination => sprintf("%s-%s", $namespace, $job_type), body => $json_args } ) or Koha::Exceptions::Exception->throw('Job has not been enqueued'); } ); diff --git a/misc/background_jobs_worker.pl b/misc/background_jobs_worker.pl index 8ce187a6b0..9844c967a6 100755 --- a/misc/background_jobs_worker.pl +++ b/misc/background_jobs_worker.pl @@ -24,8 +24,10 @@ my $conn = Koha::BackgroundJob->connect; my @job_types = qw( batch_biblio_record_modification batch_authority_record_modification ); +# FIXME cf note in Koha::BackgroundJob about $namespace +my $namespace = C4::Context->config('memcached_namespace'); for my $job_type ( @job_types ) { - $conn->subscribe({ destination => $job_type, ack => 'client' }); + $conn->subscribe({ destination => sprintf("%s-%s", $namespace, $job_type), ack => 'client' }); } while (1) { my $frame = $conn->receive_frame; -- 2.11.0