|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | namespace OldSound\RabbitMqBundle\RabbitMq; |
| 4 | + |
4 | 5 | use OldSound\RabbitMqBundle\Event\AMQPEvent; |
5 | 6 | use PhpAmqpLib\Channel\AMQPChannel; |
6 | 7 | use PhpAmqpLib\Connection\AbstractConnection; |
@@ -74,6 +75,11 @@ public function __construct(AbstractConnection $conn, AMQPChannel $ch = null, $c |
74 | 75 | } |
75 | 76 |
|
76 | 77 | public function __destruct() |
| 78 | + { |
| 79 | + $this->close(); |
| 80 | + } |
| 81 | + |
| 82 | + public function close() |
77 | 83 | { |
78 | 84 | if ($this->ch) { |
79 | 85 | try { |
@@ -115,6 +121,7 @@ public function getChannel() |
115 | 121 |
|
116 | 122 | /** |
117 | 123 | * @param AMQPChannel $ch |
| 124 | + * |
118 | 125 | * @return void |
119 | 126 | */ |
120 | 127 | public function setChannel(AMQPChannel $ch) |
@@ -158,6 +165,33 @@ public function setRoutingKey($routingKey) |
158 | 165 | $this->routingKey = $routingKey; |
159 | 166 | } |
160 | 167 |
|
| 168 | + public function setupFabric() |
| 169 | + { |
| 170 | + if (!$this->exchangeDeclared) { |
| 171 | + $this->exchangeDeclare(); |
| 172 | + } |
| 173 | + |
| 174 | + if (!$this->queueDeclared) { |
| 175 | + $this->queueDeclare(); |
| 176 | + } |
| 177 | + } |
| 178 | + |
| 179 | + /** |
| 180 | + * disables the automatic SetupFabric when using a consumer or producer |
| 181 | + */ |
| 182 | + public function disableAutoSetupFabric() |
| 183 | + { |
| 184 | + $this->autoSetupFabric = false; |
| 185 | + } |
| 186 | + |
| 187 | + /** |
| 188 | + * @param LoggerInterface $logger |
| 189 | + */ |
| 190 | + public function setLogger($logger) |
| 191 | + { |
| 192 | + $this->logger = $logger; |
| 193 | + } |
| 194 | + |
161 | 195 | /** |
162 | 196 | * Declares exchange |
163 | 197 | */ |
@@ -217,32 +251,6 @@ protected function queueBind($queue, $exchange, $routing_key) |
217 | 251 | } |
218 | 252 | } |
219 | 253 |
|
220 | | - public function setupFabric() |
221 | | - { |
222 | | - if (!$this->exchangeDeclared) { |
223 | | - $this->exchangeDeclare(); |
224 | | - } |
225 | | - |
226 | | - if (!$this->queueDeclared) { |
227 | | - $this->queueDeclare(); |
228 | | - } |
229 | | - } |
230 | | - |
231 | | - /** |
232 | | - * disables the automatic SetupFabric when using a consumer or producer |
233 | | - */ |
234 | | - public function disableAutoSetupFabric() { |
235 | | - $this->autoSetupFabric = false; |
236 | | - } |
237 | | - |
238 | | - /** |
239 | | - * @param LoggerInterface $logger |
240 | | - */ |
241 | | - public function setLogger($logger) |
242 | | - { |
243 | | - $this->logger = $logger; |
244 | | - } |
245 | | - |
246 | 254 | /** |
247 | 255 | * @param EventDispatcherInterface $eventDispatcher |
248 | 256 | * |
|
0 commit comments