Skip to content

Commit 903ddc0

Browse files
authored
Update RabbitMQQueue.php
1 parent 5191a2b commit 903ddc0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Queue/RabbitMQQueue.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ public function push($job, $data = '', $queue = null)
106106
$this->createPayload($job, $this->getQueue($queue), $data),
107107
$queue,
108108
null,
109-
function ($payload, $queue) {
110-
return $this->pushRaw($payload, $queue);
109+
function ($payload, $queue) use ($job) {
110+
return $this->pushRaw($payload, $queue, [
111+
'job' => $job
112+
]);
111113
}
112114
);
113115
}
@@ -119,11 +121,11 @@ function ($payload, $queue) {
119121
*/
120122
public function pushRaw($payload, $queue = null, array $options = []): int|string|null
121123
{
122-
[$destination, $exchange, $exchangeType, $attempts] = $this->publishProperties($queue, $options);
124+
[$destination, $exchange, $exchangeType, $attempts, $job] = $this->publishProperties($queue, $options);
123125

124126
$this->declareDestination($destination, $exchange, $exchangeType);
125127

126-
[$message, $correlationId] = $this->createMessage($payload, $attempts);
128+
[$message, $correlationId] = $this->createMessage($payload, $attempts, $job);
127129

128130
$this->publishBasic($message, $exchange, $destination, true);
129131

@@ -511,7 +513,7 @@ public function reject(RabbitMQJob $job, bool $requeue = false): void
511513
/**
512514
* Create a AMQP message.
513515
*/
514-
protected function createMessage($payload, int $attempts = 0): array
516+
protected function createMessage($payload, int $attempts = 0, string $job = null): array
515517
{
516518
$properties = [
517519
'content_type' => 'application/json',
@@ -542,6 +544,8 @@ protected function createMessage($payload, int $attempts = 0): array
542544
$message = new AMQPMessage($payload, $properties);
543545

544546
$message->set('application_headers', new AMQPTable([
547+
'rr_job' => $job,
548+
'rr_id' => $correlationId,
545549
'laravel' => [
546550
'attempts' => $attempts,
547551
],

0 commit comments

Comments
 (0)