-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] [Amqp] Handle AMQPConnectionException when publishing a message. #54167
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
Conversation
Hey! Thanks for your PR. You are targeting branch "7.1" but it seems your PR description refers to branch "6.4". Cheers! Carsonbot |
if (++$retries <= $maxRetries) { | ||
$this->clear(); | ||
|
||
goto retry; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cost years of public bashing, but I guess we can afford it 🥲
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💘 goto, no shame :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehehe I like it too. I feel like imo it reads better than a loop specifically for retry logic.
Thank you @jwage. |
Lovely. Thank you |
@nicolas-grekas @chalasr @Nyholm thinking more about this. Does this retry open up the possibility for a double publish? What if the write succeeds on the server but the client loses the connection and exception is thrown before getting the response to the write? Then we retry and double publish. Since this isn't idempotent and we have no guarantees, I don't think we can generically retry. @dunglas see the above. This is related to our discussion about not being able to safely retry non idempotent queries automatically in Doctrine. Asked here as well php-amqp/php-amqp#548 |
@chalasr @nicolas-grekas is there a way to add this fix into the LTS 5.4 Version? Many thanks! |
Hey @xabbuh thank you very much!! 🍻 |
…ng a message (jwage) This PR was merged into the 5.4 branch. Discussion ---------- [Messenger] Handle `AMQPConnectionException` when publishing a message | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | backport of #54167 | License | MIT Commits ------- e10aa0e [Messenger] [Amqp] Handle AMQPConnectionException when publishing a message.
If you have a message handler that dispatches messages to another queue, you can encounter
AMQPConnectionException
with the message "Library error: a SSL error occurred" or "a socket error occurred" depending on if you are using tls or not or if you are running behind a load balancer or not.You can manually reproduce this issue by dispatching a message where the handler then dispatches another message to a different queue, then go to rabbitmq admin and close the connection manually, then dispatch another message and when the message handler goes to dispatch the other message, you will get this exception:
TODO: