Skip to content
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

Refactor client to return error on receiver.Receive #707

Closed

Conversation

oleg-kulyk
Copy link
Contributor

Signed-off-by: Oleg Kulyk oleg.kulyk@checkmarx.com

Fixes #685 and #684

Current behavior locks down consumer in an infinite loop if connection to Rabbitmq is closed. When analyzing the client code I saw no real purpose in "hiding" error coming from Receiver and just continuing running.

Current change should not introduce any b/c breaking issues, unless the client code depends on consumer not "dying" if connection is lost (for which I struggle to come up with a meaningful example).

The fix for test came after inspecting locally what would be the outcome if err is retuned (in which case test panicked because of "fail" in running goroutine after the t.Run process is finished).

Signed-off-by: Oleg Kulyk <oleg.kulyk@checkmarx.com>
if err != nil {
cecontext.LoggerFrom(ctx).Warn("Error while receiving a message: ", err)
continue
errChan <- err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not all errors cause all protocols to not respond, some would like the message to be returned via Invoke, this change does not seem like it will work for all protocols.

Is there a change to the amqp impl that would allow it to handle the error? Like, perhaps it needs to respond with a io.EOF when the the server is disconnected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review.

I think it does make send to send io.EOF in case connection is down, I'll look in that direction.

@oleg-kulyk
Copy link
Contributor Author

closing in favor of #750

@oleg-kulyk oleg-kulyk closed this Dec 26, 2021
@oleg-kulyk oleg-kulyk deleted the connection_error_handling branch December 26, 2021 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to reconnect amqp if session ended by server
2 participants