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

Commit 656e77e

Browse files
committed
Fixes correlationId on publish
1 parent 62c92e5 commit 656e77e

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
/**
@@ -267,4 +269,14 @@ public function setCorrelationId($id)
267269
{
268270
$this->correlationId = $id;
269271
}
272+
273+
/**
274+
* Retrieves the correlation id, or a unique id
275+
*
276+
* @return string
277+
*/
278+
public function getCorrelationId()
279+
{
280+
return $this->correlationId ?: uniqid();
281+
}
270282
}

0 commit comments

Comments
 (0)