Skip to content

[Messenger][AMQP] Automatically reconnect on connection loss #53892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ private function getEnvelope(string $queueName): iterable
{
try {
$amqpEnvelope = $this->connection->get($queueName);
} catch (\AMQPConnectionException) {
// Try to reconnect once to accommodate need for one of the nodes in cluster needing to stop serving the
// traffic. This may happen for example when one of the nodes in cluster is going into maintenance node.
// see https://github.com/php-amqplib/php-amqplib/issues/1161
try {
$this->connection->queue($queueName)->getConnection()->reconnect();
$amqpEnvelope = $this->connection->get($queueName);
} catch (\AMQPException $exception) {
throw new TransportException($exception->getMessage(), 0, $exception);
}
} catch (\AMQPException $exception) {
throw new TransportException($exception->getMessage(), 0, $exception);
}
Expand Down