Skip to content

Commit de22d9a

Browse files
author
Alessandro Chitolina
committed
added durable and auto_delete options to exchange configuration
1 parent 20bde56 commit de22d9a

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/Child.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public function run()
7575
$this->queue = new AmqpLibQueue($this->logger, $connection, $this->options['queue_name'], $this->eventDispatcher);
7676

7777
if (!empty($this->options['exchange'])) {
78-
$this->queue->setExchange($this->options['exchange']['name'], $this->options['exchange']['type']);
78+
$ex_options = $this->options['exchange'];
79+
$this->queue->setExchange($ex_options['name'], $ex_options['type'], $ex_options['durable'], $ex_options['auto_delete']);
7980
}
8081

8182
$this->eventDispatcher->dispatch(Events::CHILD_START, new ChildStartEvent($this));

src/DependencyInjection/Configuration.php

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ private function addQueuesNode(NodeDefinition $root)
9898
->end()
9999
->defaultValue('fanout')
100100
->end()
101+
->booleanNode('durable')->defaultTrue()->end()
102+
->booleanNode('auto_delete')->defaultFalse()->end()
101103
->end()
102104
->end()
103105
->arrayNode('worker')

src/Queue/AmqpLibQueue.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ public function publishMessage($data)
104104
$this->channel->basic_publish($message, '', $this->queue);
105105
}
106106

107-
public function setExchange($name, $type)
107+
public function setExchange($name, $type, $durable, $auto_delete)
108108
{
109-
$this->channel->exchange_declare($name, $type);
109+
$this->channel->exchange_declare($name, $type, $durable, $auto_delete);
110110
$this->channel->queue_bind($this->queue, $name);
111111
}
112112

src/Queue/QueueInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface QueueInterface
66
{
77
public function runLoop();
88

9-
public function setExchange($name, $type);
9+
public function setExchange($name, $type, $durable, $auto_delete);
1010

1111
public function publishMessage($data);
1212

0 commit comments

Comments
 (0)