The package provides an auto reconnect feature for streadway/amqp. The approach idea is to add as little abstraction as possible. In your code instead of using *amqp.Connection
you should use <-chan *amqp.Connection
. The channel returns a healthy connection. You should subscribe to chan *amqp.Error
to get notified when a connection is not helthy any more and you should request a new one via <-chan *amqp.Connection
. The channel <-chan *amqp.Connection
is closed when you explicitly closed it by calling connextra.Close()
method, otherwise, it tries to reconnect in background.
See an example.
The package provides a handy consumer. It is aware of <-chan *amqp.Connection
and <-chan *amqp.Error
and can work with them respectively.
It also starts multiple works in background and correctly stop them when needed.
See an example.
The consumer could chain middlewares for pre precessing received message. Check an example that rejects messages without correlation_id and reply_to properties.
See an example.
The package provides a handy publisher. It is aware of <-chan *amqp.Connection
and <-chan *amqp.Error
and can work with them respectively.
See an example.