Lines 117-142
sub enqueue {
Link Here
|
117 |
$job_id = $self->id; |
117 |
$job_id = $self->id; |
118 |
$job_args->{job_id} = $job_id; |
118 |
$job_args->{job_id} = $job_id; |
119 |
$json_args = encode_json $job_args; |
119 |
$json_args = encode_json $job_args; |
120 |
|
|
|
121 |
try { |
122 |
my $conn = $self->connect; |
123 |
# This namespace is wrong, it must be a vhost instead. |
124 |
# But to do so it needs to be created on the server => much more work when a new Koha instance is created. |
125 |
# Also, here we just want the Koha instance's name, but it's not in the config... |
126 |
# Picking a random id (memcached_namespace) from the config |
127 |
my $namespace = C4::Context->config('memcached_namespace'); |
128 |
$conn->send_with_receipt( { destination => sprintf("/queue/%s-%s", $namespace, $job_type), body => $json_args } ) |
129 |
or Koha::Exceptions::Exception->throw('Job has not been enqueued'); |
130 |
} catch { |
131 |
if ( ref($_) eq 'Koha::Exceptions::Exception' ) { |
132 |
$_->rethrow; |
133 |
} else { |
134 |
warn sprintf "The job has not been sent to the message broker: (%s)", $_; |
135 |
} |
136 |
}; |
137 |
} |
120 |
} |
138 |
); |
121 |
); |
139 |
|
122 |
|
|
|
123 |
Koha::Exceptions::Exception->throw('Job has not been enqueued') |
124 |
unless $job_id; |
125 |
|
126 |
try { |
127 |
my $conn = $self->connect; |
128 |
# This namespace is wrong, it must be a vhost instead. |
129 |
# But to do so it needs to be created on the server => much more work when a new Koha instance is created. |
130 |
# Also, here we just want the Koha instance's name, but it's not in the config... |
131 |
# Picking a random id (memcached_namespace) from the config |
132 |
my $namespace = C4::Context->config('memcached_namespace'); |
133 |
$conn->send_with_receipt( { destination => sprintf("/queue/%s-%s", $namespace, $job_type), body => $json_args } ) |
134 |
or Koha::Exceptions::Exception->throw('Job has not been enqueued'); |
135 |
} catch { |
136 |
if ( ref($_) eq 'Koha::Exceptions::Exception' ) { |
137 |
$_->rethrow; |
138 |
} else { |
139 |
warn sprintf "The job has not been sent to the message broker: (%s)", $_; |
140 |
} |
141 |
}; |
142 |
|
140 |
return $job_id; |
143 |
return $job_id; |
141 |
} |
144 |
} |
142 |
|
145 |
|
143 |
- |
|
|