Allows to send simple RabbitMq message periodically.
git clone https://github.com/1001Pharmacies/rabbitmq-scheduler.git
cd rabbitmq-scheduler
make install
Add crontab (crontab -e
)
* * * * * cd /path/to/rabbitmq-scheduler && php bin/console rabbitmq-scheduler:run
make install -e ENV=prod
Settings are stored in parameters.php
.
You can setup planned tasks in parameters.php
file :
<?php
use Task\Task;
return [
'tasks' => [
Task::create('Name', '0 0 * * *', ['my' => 'message'], 'routing-key'),
Task::create('Name 2', '@daily', ['my' => 'message'], 'routing-key-2'),
],
];
Setup your RabbitMq connection in parameters.php
file :
<?php
return [
'tasks' => [],
'rabbitmq' => [
'host' => 'localhost',
'port' => 5672,
'user' => 'guest',
'password' => 'guest',
'vhost' => '/',
'exchange' => 'scheduler',
'exchange_type' => 'direct',
],
];
The scheduler will put every message in the same exchange, use the task routing key for dispatching.