Skip to content

Commit 78404f3

Browse files
author
Alessandro Chitolina
committed
declare exchange on queue if set in configuration
1 parent ca79314 commit 78404f3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Child.php

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ public function run()
6969
$connection = $this->connectionManager->getConnection($this->options['connection']);
7070
$this->queue = new AmqpLibQueue($this->logger, $connection, $this->options['queue_name']);
7171

72+
if ($this->options['exchange']) {
73+
$this->queue->setExchange($this->options['exchange']['name'], $this->options['exchange']['type']);
74+
}
75+
7276
$this->eventDispatcher->dispatch(Events::CHILD_START, new ChildStartEvent($this));
7377
$this->logger->info('Started. Waiting for jobs...');
7478

src/Queue/AmqpLibQueue.php

+5
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ public function processMessage(AMQPMessage $msg)
104104
$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
105105
}
106106

107+
public function setExchange($name, $type)
108+
{
109+
$this->channel->exchange_declare($name, $type);
110+
}
111+
107112
public function setSymfonyConsoleApp($console)
108113
{
109114
$this->symfony_app = $console;

0 commit comments

Comments
 (0)