1 | <?php |
||
25 | class AMQPBackendDispatcher extends QueueBackendDispatcher |
||
26 | { |
||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $settings; |
||
31 | |||
32 | /** |
||
33 | * @var AMQPChannel |
||
34 | */ |
||
35 | protected $channel; |
||
36 | |||
37 | /** |
||
38 | * @var AMQPConnection |
||
39 | */ |
||
40 | protected $connection; |
||
41 | |||
42 | /** |
||
43 | * @param array $settings |
||
44 | * @param array $queues |
||
45 | * @param string $defaultQueue |
||
46 | * @param array $backends |
||
47 | */ |
||
48 | public function __construct(array $settings, array $queues, $defaultQueue, array $backends) |
||
49 | { |
||
50 | parent::__construct($queues, $defaultQueue, $backends); |
||
51 | |||
52 | $this->settings = $settings; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return AMQPChannelannel |
||
57 | */ |
||
58 | public function getChannel() |
||
59 | { |
||
60 | if (!$this->channel) { |
||
61 | $this->connection = new AMQPConnection( |
||
|
|||
62 | $this->settings['host'], |
||
63 | $this->settings['port'], |
||
64 | $this->settings['user'], |
||
65 | $this->settings['pass'], |
||
66 | $this->settings['vhost'] |
||
67 | ); |
||
68 | |||
69 | $this->channel = $this->connection->channel(); |
||
70 | |||
71 | register_shutdown_function(array($this, 'shutdown')); |
||
72 | } |
||
73 | |||
74 | return $this->channel; |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | public function getBackend($type) |
||
112 | |||
113 | /** |
||
114 | * {@inheritdoc} |
||
115 | */ |
||
116 | public function getIterator() |
||
117 | { |
||
118 | throw new \RuntimeException('You need to use a specific rabbitmq backend supporting the selected queue to run a consumer.'); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * {@inheritdoc} |
||
123 | */ |
||
124 | public function handle(MessageInterface $message, EventDispatcherInterface $dispatcher) |
||
125 | { |
||
126 | throw new \RuntimeException('You need to use a specific rabbitmq backend supporting the selected queue to run a consumer.'); |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * {@inheritdoc} |
||
131 | */ |
||
132 | public function getStatus() |
||
164 | |||
165 | /** |
||
166 | * {@inheritdoc} |
||
167 | */ |
||
168 | public function cleanup() |
||
172 | |||
173 | public function shutdown() |
||
183 | |||
184 | /** |
||
185 | * {@inheritdoc} |
||
186 | */ |
||
187 | public function initialize() |
||
190 | |||
191 | /** |
||
192 | * Calls the rabbitmq management api /api/<vhost>/queues endpoint to list the available queues. |
||
193 | * |
||
194 | * @see http://hg.rabbitmq.com/rabbitmq-management/raw-file/3646dee55e02/priv/www-api/help.html |
||
195 | * |
||
196 | * @return array |
||
197 | */ |
||
198 | protected function getApiQueueStatus() |
||
211 | } |
||
212 |
This class, trait or interface has been deprecated.