Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d5b946d

Browse files
committed
[Messenger] AMQP:Automatically reconnect on connection loss
1 parent bc2d994 commit d5b946d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ private function getEnvelope(string $queueName): iterable
5252
{
5353
try {
5454
$amqpEnvelope = $this->connection->get($queueName);
55+
} catch (\AMQPConnectionException) {
56+
// Try to reconnect once to accommodate need for one of the nodes in cluster needing to stop serving the
57+
// traffic. This may happen for example when one of the nodes in cluster is going into maintenance node.
58+
// see https://github.com/php-amqplib/php-amqplib/issues/1161
59+
$this->connection->queue($queueName)->getConnection()->reconnect();
60+
$amqpEnvelope = $this->connection->get($queueName);
5561
} catch (\AMQPException $exception) {
5662
throw new TransportException($exception->getMessage(), 0, $exception);
5763
}

0 commit comments

Comments
 (0)