Skip to content

apsyadira-jubelio/go-amqp-reconnect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-amqp-reconnect

auto reconnecting library for https://github.com/streadway/amqp, that doesn't reconnect on server shutdown To simply developers, here is auto reconnect wrap with detail comments.

This library based on https://github.com/isayme/go-amqp-reconnect, but also supports some external methods.

Methods

  1. rabbitmq.Dial(url) & rabbitmq.DialConfig(url, config) - creates connection with reconnect
  2. connection.Channel() - creates channel with reconnect
  3. connection.Close() - clearly closes channel without reconnect
  4. channel.Qos() - restore settings for channel
  5. channel.QueueDeclare() & channel.QueueDeclarePassive() - restore autoDeleted queues
  6. channel.ExchangeDeclare() & channel.ExchangeDeclarePassive() - restores autoDeleted exchanges
  7. channel.Close() - clearly closes channel without reconnect

Another methods call through aliases with mutex, to avoid race condition

How to change existing code

  1. add import import "github.com/apsyadira-jubelio/go-amqp-reconnect/rabbitmq"
  2. Replace amqp.Connection/amqp.Channel with rabbitmq.Connection/rabbitmq.Channel!

Debug

You can set rabbitmq.Debug = true variable to view debug messages

Settings

  1. rabbitmq.ReconnectDelay determines time that app wait for new reconnect try, defaults to time.Second * 3

Examples

Close with reconnect

go run examples/close_with_reconnect/demo.go -url=amqp://user:password@host:port/

after start, drop connection through RabbitMQ management panel on connection tabs, or restart RabbitMQ server

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published