Bug 22417: Restore the concept of namespace
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 20 Feb 2020 15:39:13 +0000 (16:39 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 5 Oct 2020 13:22:44 +0000 (15:22 +0200)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/BackgroundJob.pm
misc/background_jobs_worker.pl

index 4479e51..7cf2814 100644 (file)
@@ -48,7 +48,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');
         }
     );
index 882c8a0..0127a2c 100755 (executable)
@@ -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;