Skip to content
This repository was archived by the owner on Sep 3, 2020. It is now read-only.

Commit b928f01

Browse files
Creating delayed queues in the same exchange as the master queue.
Unserializing the job from the new (Laravel 5.2) queued process.
1 parent e08a827 commit b928f01

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/Jobs/RabbitMQJob.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ public function release($delay = 0)
8989

9090
$attempts = $this->attempts();
9191

92-
// write attempts to body
93-
$body['data']['attempts'] = $attempts + 1;
92+
$job = unserialize($body['data']['command']);
93+
94+
// write attempts to job
95+
$job->attempts = $attempts + 1;
9496

95-
$job = $body['job'];
9697
$data = $body['data'];
9798

9899
if ($delay > 0) {

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/RabbitMQQueue.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,13 @@ private function declareDelayedQueue($destination, $delay)
185185
{
186186
$delay = $this->getSeconds($delay);
187187
$destination = $this->getQueueName($destination);
188+
$destinationExchange = $this->configExchange['name'] ?:$destination;
188189
$name = $this->getQueueName($destination) . '_deferred_' . $delay;
189-
$exchange = $this->configExchange['name'] ?:$name;
190+
$exchange = $this->configExchange['name'] ?:$destination;
190191

191192
// declare exchange
192193
$this->channel->exchange_declare(
193-
$exchange,
194+
$exchange,
194195
$this->configExchange['type'],
195196
$this->configExchange['passive'],
196197
$this->configExchange['durable'],
@@ -199,14 +200,14 @@ private function declareDelayedQueue($destination, $delay)
199200

200201
// declare queue
201202
$this->channel->queue_declare(
202-
$name,
203+
$name,
203204
$this->configQueue['passive'],
204205
$this->configQueue['durable'],
205206
$this->configQueue['exclusive'],
206207
$this->configQueue['auto_delete'],
207-
false,
208+
false ,
208209
new AMQPTable([
209-
'x-dead-letter-exchange' => $destination,
210+
'x-dead-letter-exchange' => $destinationExchange,
210211
'x-dead-letter-routing-key' => $destination,
211212
'x-message-ttl' => $delay * 1000,
212213
])

0 commit comments

Comments
 (0)