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

Client Example: Fix closing order #35

Merged
merged 1 commit into from
Jan 20, 2022
Merged

Client Example: Fix closing order #35

merged 1 commit into from
Jan 20, 2022

Conversation

andygrunwald
Copy link
Contributor

In the client example, the order on how to close elements of the session is wrong:

func (session *Session) Close() error {
if !session.isReady {
return errAlreadyClosed
}
err := session.channel.Close()
if err != nil {
return err
}
err = session.connection.Close()
if err != nil {
return err
}
close(session.done)
session.isReady = false
return nil
}

If you first close the channel and after consider the session as done, the reconnection logic will try to re-create the channel and re-init the queue (in the example).
if you first close the done channel, you indicate that we are done with the session and the reconnection logic will end.

@michaelklishin
Copy link
Member

This example really suffers from a newly invented concept, "session", and the confusion between AMQP 0-9-1 channels and Go channels :(

@michaelklishin michaelklishin merged commit 51fade5 into rabbitmq:main Jan 20, 2022
@michaelklishin
Copy link
Member

Thank you!

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.

2 participants