twn39/rabbitmq-delay-message

rabbitmq delay message for laravel.

1.1.1 2016-12-20 07:39 UTC

This package is auto-updated.

Last update: 2024-12-21 21:47:24 UTC


README

config/app.php中加入:

 Wang\RabbitMQ\RabbitMQServiceProvider::class

执行命令:

php artisan vendor:publish

Publish

$delayMessage = app(DelayedMessage::class);

$delayMessage->setExchange('delay-exchange');
$delayMessage->setQueue('delay-queue');

$delayMessage->publish([
    'name' => 'Tang',
    'age' => 22,
], 5000);

return 'success';

Consume

$delayMessage = app(DelayedMessage::class);

$delayMessage->setExchange('delay-exchange');
$delayMessage->setQueue('delay-queue');

$delayMessage->consume(function (AMQPMessage $message) {
    var_dump(json_decode($message->body, true));
});