$this->
setupDelayExchange();
} $queue =
$this->
createDelayQueue($delay,
$routingKey,
$isRetryAttempt);
$queue->
declareQueue(); // the delay queue always need to be declared because the name is dynamic and cannot be declared in advance
$queue->
bind($this->connectionOptions
['delay'
]['exchange_name'
],
$this->
getRoutingKeyForDelay($delay,
$routingKey,
$isRetryAttempt));
} private function getDelayExchange(): \AMQPExchange
{ if (!
isset($this->amqpDelayExchange
)) { $this->amqpDelayExchange =
$this->amqpFactory->
createExchange($this->
channel());
$this->amqpDelayExchange->
setName($this->connectionOptions
['delay'
]['exchange_name'
]);
$this->amqpDelayExchange->
setType(\AMQP_EX_TYPE_DIRECT
);
$this->amqpDelayExchange->
setFlags(\AMQP_DURABLE
);
} return $this->amqpDelayExchange;
} /**
* Creates a delay queue that will delay for a certain amount of time.
*
* This works by setting message TTL for the delay and pointing
* the dead letter exchange to the original exchange. The result
* is that after the TTL, the message is sent to the dead-letter-exchange,
* which is the original exchange, resulting on it being put back into
* the original queue.
*/