2016-09-09 19:02:03 +00:00
|
|
|
<?php
|
|
|
|
|
2023-12-31 20:13:25 +00:00
|
|
|
namespace Wallabag\CoreBundle\Redis;
|
2016-09-09 19:02:03 +00:00
|
|
|
|
|
|
|
use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
|
|
|
|
use Simpleue\Queue\RedisQueue;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a proxy class for "Simpleue\Queue\RedisQueue".
|
|
|
|
* It allow us to use the same way to publish a message between RabbitMQ & Redis: publish().
|
|
|
|
*
|
|
|
|
* It implements the ProducerInterface of RabbitMQ (yes it's ugly) so we can have the same
|
|
|
|
* kind of class which implements the same interface.
|
|
|
|
* So we can inject either a RabbitMQ producer or a Redis producer with the same signature
|
|
|
|
*/
|
|
|
|
class Producer implements ProducerInterface
|
|
|
|
{
|
|
|
|
private $queue;
|
|
|
|
|
|
|
|
public function __construct(RedisQueue $queue)
|
|
|
|
{
|
|
|
|
$this->queue = $queue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Publish a message in the Redis queue.
|
|
|
|
*
|
|
|
|
* @param string $msgBody
|
|
|
|
* @param string $routingKey NOT USED
|
|
|
|
* @param array $additionalProperties NOT USED
|
|
|
|
*/
|
2017-07-01 07:52:38 +00:00
|
|
|
public function publish($msgBody, $routingKey = '', $additionalProperties = [])
|
2016-09-09 19:02:03 +00:00
|
|
|
{
|
|
|
|
$this->queue->sendJob($msgBody);
|
|
|
|
}
|
|
|
|
}
|