Skip to content

Commit 747f356

Browse files
committed
Merge pull request vyuldashev#59 from Toolstation/toolstation
Corrections for delayed queues
2 parents deffb7a + a5f39b3 commit 747f356

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
}
2222
},
2323
"minimum-stability": "stable"
24-
}
24+
}

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)