vcabbage / amqp

AMQP 1.0 client library for Go.
https://godoc.org/pack.ag/amqp
MIT License
134 stars 97 forks source link

Best Practices for Sessions #180

Closed borlinp closed 4 years ago

borlinp commented 4 years ago

We are building a new project with this library. I see there is a Client, Session, Receiver, and Sender. What is the best practices for retaining an instance of each of those? Here are my assumptions from having use AMQP in the past:

Please help me correct my assumptions so that we use these correctly. Thanks.

vcabbage commented 4 years ago

In my own usage I create one client, session, and receiver. If an error occurs, such as a network problem, I close and re-create all three.

I'm afraid I don't have any general advice as far as performance goes. All sends and receives are multiplexed over the same client/connection, so it's possible that multiple clients could provide a benefit. I haven't done any testing in this area.

Sorry I'm unable to provide more concrete advice.

borlinp commented 4 years ago

If we discover a good pattern, we'll let you know. For now, we are going to keep one client for the life of the application, and create the other 3 on demand. Thanks.