I would like to know how to delay with Amqpphplib.
I used this great coffee script tutorial :
https://github.com/jamescarr/rabbitmq-scheduled-delivery
<
If you choose amqp interop based transport you won't need to dig into details at all. Only a few things to do:
Install enqueue/amqp-lib
(btw you can use other transports based on amqp ext and a great bunny lib) transport and enqueue/amqp-tools
.
composer require enqueue/amqp-lib enqueue/amqp-tools
Create amqp context, add a delay strategy and send delayed messages:
createContext();
$context->setDelayStrategy(new RabbitMqDlxDelayStrategy())
$queue = $context->createQueue('foo');
$context->declareQueue($queue);
$message = $context->createMessage('Hello world!');
$context->createProducer()
->setDeliveryDelay(5000) // 5 sec
->send($queue, $message)
;
By the way, this not this only strategy available. there is one based on RabbitMQ delay plugin. It could be used the same way.