Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Queue/RabbitMQQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function pushRaw($payload, $queue = null, array $options = [])

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

[$message, $correlationId] = $this->createMessage($payload, $attempts);
[$message, $correlationId] = $this->createMessage($payload, $attempts, $options);

$this->channel->basic_publish($message, $exchange, $destination, true, false);

Expand Down Expand Up @@ -522,24 +522,27 @@ public function reject(RabbitMQJob $job, bool $requeue = false): void
*
* @param $payload
* @param int $attempts
* @param array $options
* @return array
* @throws JsonException
*/
protected function createMessage($payload, int $attempts = 0): array
protected function createMessage($payload, int $attempts = 0, $options = []): array
{
$properties = [
'content_type' => 'application/json',
'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT,
];

if ($correlationId = json_decode($payload, true, 512)['id'] ?? null) {
if ($correlationId = $options['correlation_id'] ?? json_decode($payload, true, 512)['id'] ?? null) {
$properties['correlation_id'] = $correlationId;
}

if ($this->isPrioritizeDelayed()) {
$properties['priority'] = $attempts;
}

$properties += $options;

$message = new AMQPMessage($payload, $properties);

$message->set('application_headers', new AMQPTable([
Expand Down