aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Redis/Producer.php
blob: c77b51747e55d0278dc46849989f91d57e673381 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

namespace Wallabag\ImportBundle\Redis;

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
     */
    public function publish($msgBody, $routingKey = '', $additionalProperties = [])
    {
        $this->queue->sendJob($msgBody);
    }
}