8000 [Messenger][Amqp] Call `setType` of the exchange with a proper defaul… · symfony/symfony@8e07524 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8e07524

Browse files
committed
[Messenger][Amqp] Call setType of the exchange with a proper default type
1 parent 74be39a commit 8e07524

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ public function testGettingDefaultExchange()
884884

885885
$amqpExchange = $this->createMock(\AMQPExchange::class);
886886
$amqpExchange->expects($this->once())->method('setName')->with('');
887-
$amqpExchange->expects($this->never())->method('setType');
887+
$amqpExchange->expects($this->once())->method('setType')->with(\AMQP_EX_TYPE_DIRECT);
888888
$amqpExchange->expects($this->never())->method('setFlags');
889889
$amqpExchange->expects($this->never())->method('setArguments');
890890

src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,9 @@ public function exchange(): \AMQPExchange
539539
if (!isset($this->amqpExchange)) {
540540
$this->amqpExchange = $this->amqpFactory->createExchange($this->channel());
541541
$this->amqpExchange->setName($this->exchangeOptions['name']);
542+
$defaultExchangeType = '' !== $this->exchangeOptions['name'] ? \AMQP_EX_TYPE_FANOUT : \AMQP_EX_TYPE_DIRECT;
543+
$this->amqpExchange->setType($this->exchangeOptions['type'] ?? $defaultExchangeType);
542544
if ('' !== $this->exchangeOptions['name']) {
543-
$this->amqpExchange->setType($this->exchangeOptions['type'] ?? \AMQP_EX_TYPE_FANOUT);
544545
$this->amqpExchange->setFlags($this->exchangeOptions['flags'] ?? \AMQP_DURABLE);
545546

546547
if (isset($this->exchangeOptions['arguments'])) {

0 commit comments

Comments
 (0)
0