Skip to content

Commit ccefefd

Browse files
committed
Fixes correlationId on publish
1 parent dbcd3df commit ccefefd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/RabbitMQQueue.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ public function pushRaw($payload, $queue = null, array $options = [])
9898

9999
// push job to a queue
100100
$message = new AMQPMessage($payload, $headers);
101-
$message->set('correlation_id', $this->correlationId ?: uniqid());
101+
102+
$correlationId = $this->getCorrelationId();
103+
$message->set('correlation_id', $correlationId);
102104

103105
// push task to a queue
104106
$this->channel->basic_publish($message, $exchange, $queue);
105107

106-
return $this->message->get('correlation_id');
108+
return $correlationId;
107109
}
108110

109111
/**
@@ -266,4 +268,14 @@ public function setCorrelationId($id)
266268
{
267269
$this->correlationId = $id;
268270
}
271+
272+
/**
273+
* Retrieves the correlation id, or a unique id
274+
*
275+
* @return string
276+
*/
277+
public function getCorrelationId()
278+
{
279+
return $this->correlationId ?: uniqid();
280+
}
269281
}

0 commit comments

Comments
 (0)