@@ 14-74 (lines=61) @@ | ||
11 | use Cmobi\RabbitmqBundle\Queue\QueueServiceInterface; |
|
12 | use Psr\Log\LoggerInterface; |
|
13 | ||
14 | class RpcServerBuilder implements QueueBuilderInterface |
|
15 | { |
|
16 | private $connectionManager; |
|
17 | private $logger; |
|
18 | private $parameters; |
|
19 | ||
20 | public function __construct(ConnectionManager $connManager, LoggerInterface $logger, array $parameters) |
|
21 | { |
|
22 | $this->connectionManager = $connManager; |
|
23 | $this->logger = $logger; |
|
24 | $this->parameters = $parameters; |
|
25 | $this->channel = null; |
|
26 | } |
|
27 | ||
28 | /** |
|
29 | * @param $queueName |
|
30 | * @param QueueServiceInterface $queueService |
|
31 | * |
|
32 | * @return Queue |
|
33 | * @throws InvalidAMQPChannelException |
|
34 | */ |
|
35 | public function buildQueue($queueName, QueueServiceInterface $queueService) |
|
36 | { |
|
37 | $qos = 1; |
|
38 | ||
39 | if (array_key_exists('cmobi_rabbitmq.basic_qos', $this->parameters)) { |
|
40 | $qos = $this->parameters['cmobi_rabbitmq.basic_qos']; |
|
41 | } |
|
42 | $rpcQueueBag = new RpcQueueBag($queueName, $qos); |
|
43 | ||
44 | $queue = new Queue($this->getConnectionManager(), $rpcQueueBag, $this->logger); |
|
45 | $queueCallback = new RpcQueueCallback($queueService); |
|
46 | $queue->setCallback($queueCallback); |
|
47 | ||
48 | return $queue; |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * @return ConnectionManager |
|
53 | */ |
|
54 | public function getConnectionManager() |
|
55 | { |
|
56 | return $this->connectionManager; |
|
57 | } |
|
58 | ||
59 | /** |
|
60 | * @return string|false |
|
61 | */ |
|
62 | public function getExchangeName() |
|
63 | { |
|
64 | return false; |
|
65 | } |
|
66 | ||
67 | /** |
|
68 | * @return string|false |
|
69 | */ |
|
70 | public function getExchangeType() |
|
71 | { |
|
72 | return false; |
|
73 | } |
|
74 | } |
@@ 14-74 (lines=61) @@ | ||
11 | use Cmobi\RabbitmqBundle\Queue\QueueServiceInterface; |
|
12 | use Psr\Log\LoggerInterface; |
|
13 | ||
14 | class WorkerBuilder implements QueueBuilderInterface |
|
15 | { |
|
16 | private $connectionManager; |
|
17 | private $logger; |
|
18 | private $parameters; |
|
19 | ||
20 | public function __construct(ConnectionManager $connManager, LoggerInterface $logger, array $parameters) |
|
21 | { |
|
22 | $this->connectionManager = $connManager; |
|
23 | $this->logger = $logger; |
|
24 | $this->parameters = $parameters; |
|
25 | $this->channel = null; |
|
26 | } |
|
27 | ||
28 | /** |
|
29 | * @param $queueName |
|
30 | * @param QueueServiceInterface $queueService |
|
31 | * |
|
32 | * @return Queue |
|
33 | * @throws InvalidAMQPChannelException |
|
34 | */ |
|
35 | public function buildQueue($queueName, QueueServiceInterface $queueService) |
|
36 | { |
|
37 | $qos = 1; |
|
38 | ||
39 | if (array_key_exists('cmobi_rabbitmq.basic_qos', $this->parameters)) { |
|
40 | $qos = $this->parameters['cmobi_rabbitmq.basic_qos']; |
|
41 | } |
|
42 | $rpcQueueBag = new WorkerQueueBag($queueName, $qos); |
|
43 | ||
44 | $queue = new Queue($this->getConnectionManager(), $rpcQueueBag, $this->logger); |
|
45 | $queueCallback = new WorkerQueueCallback($queueService); |
|
46 | $queue->setCallback($queueCallback); |
|
47 | ||
48 | return $queue; |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * @return ConnectionManager |
|
53 | */ |
|
54 | public function getConnectionManager() |
|
55 | { |
|
56 | return $this->connectionManager; |
|
57 | } |
|
58 | ||
59 | /** |
|
60 | * @return string|false |
|
61 | */ |
|
62 | public function getExchangeName() |
|
63 | { |
|
64 | return false; |
|
65 | } |
|
66 | ||
67 | /** |
|
68 | * @return string|false |
|
69 | */ |
|
70 | public function getExchangeType() |
|
71 | { |
|
72 | return false; |
|
73 | } |
|
74 | } |