twn39 / rabbitmq-delay-message
rabbitmq delay message for laravel.
1.1.1
2016-12-20 07:39 UTC
Requires
- php: >=5.5.0
- php-amqplib/php-amqplib: ^2.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ^1.12
This package is auto-updated.
Last update: 2024-11-21 21:29:51 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)); });