1 | <?php |
||
17 | class QueueReader implements DomainQueueReader |
||
18 | { |
||
19 | /** |
||
20 | * @var AMQPLazyConnection |
||
21 | */ |
||
22 | protected $connection; |
||
23 | |||
24 | /** |
||
25 | * @var QueueConfig |
||
26 | */ |
||
27 | protected $queueConfig; |
||
28 | |||
29 | /** |
||
30 | * @var ExchangeConfig |
||
31 | */ |
||
32 | protected $exchangeConfig; |
||
33 | |||
34 | /** |
||
35 | * @var BindConfig |
||
36 | */ |
||
37 | protected $bindConfig; |
||
38 | |||
39 | /** |
||
40 | * @var ConsumeConfig |
||
41 | */ |
||
42 | protected $consumeConfig; |
||
43 | |||
44 | /** |
||
45 | * @var MessageHandler |
||
46 | */ |
||
47 | protected $messageHandler; |
||
48 | |||
49 | /** |
||
50 | * @var LoggerInterface |
||
51 | */ |
||
52 | protected $logger; |
||
53 | |||
54 | /** |
||
55 | * @var AMQPChannel |
||
56 | */ |
||
57 | protected $channel; |
||
58 | |||
59 | /** |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $consumerTag = ''; |
||
63 | |||
64 | /** |
||
65 | * QueueReader constructor. |
||
66 | * @param AMQPLazyConnection $connection |
||
67 | * @param QueueConfig $queueConfig |
||
68 | * @param ExchangeConfig $exchangeConfig |
||
69 | * @param BindConfig $bindConfig |
||
70 | * @param ConsumeConfig $consumeConfig |
||
71 | * @param MessageHandler $messageHandler |
||
72 | * @param LoggerInterface $logger |
||
73 | */ |
||
74 | public function __construct( |
||
92 | |||
93 | /** |
||
94 | * @param callable $callback |
||
95 | * @param int $timeout |
||
96 | * @throws ReaderException |
||
97 | * @throws TimeoutReaderException |
||
98 | */ |
||
99 | public function read(callable $callback, $timeout=0) |
||
114 | |||
115 | /** |
||
116 | * Deletes all messages from the queue |
||
117 | * @return void |
||
118 | */ |
||
119 | public function purge() |
||
124 | |||
125 | /** |
||
126 | * Creates the exchange |
||
127 | */ |
||
128 | protected function exchangeDeclare() |
||
139 | |||
140 | /** |
||
141 | * Creates the queues and binds them to the exchanges and topics |
||
142 | */ |
||
143 | protected function queueDeclareAndBind() |
||
160 | |||
161 | /** |
||
162 | * Starts consuming from the queue |
||
163 | * @param int $timeout |
||
164 | */ |
||
165 | protected function consume($timeout) |
||
181 | |||
182 | /** |
||
183 | * @throws ReaderException |
||
184 | */ |
||
185 | protected function initialize() |
||
200 | |||
201 | /** |
||
202 | * Stops the consuming of messages |
||
203 | */ |
||
204 | private function stopConsuming() |
||
215 | |||
216 | /** |
||
217 | * Destructor |
||
218 | */ |
||
219 | public function __destruct() |
||
225 | } |