Skip to content

Commit

Permalink
Optimized exchange declaration for consumer messages (#6717)
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdijia authored Apr 26, 2024
1 parent 0d6e7ac commit f66439c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ public function consume(ConsumerMessageInterface $consumerMessage): void
$channel = $connection->getConfirmChannel();
$exchange = $consumerMessage->getExchange();

if (! DeclaredExchanges::has($exchange)) {
try {
DeclaredExchanges::add($exchange);
$this->declare($consumerMessage, $channel);
} catch (Throwable $exception) {
DeclaredExchanges::remove($exchange);
throw $exception;
}
try {
DeclaredExchanges::add($exchange);
$this->declare($consumerMessage, $channel);
} catch (Throwable $exception) {
DeclaredExchanges::remove($exchange);
throw $exception;
}

$concurrent = $this->getConcurrent($consumerMessage->getPoolName());
Expand Down

0 comments on commit f66439c

Please sign in to comment.