package module
Version: v1.1.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2019 License: MIT Imports: 5 Imported by: 0


Build Status Coverage Status Go Report Card GoDoc Mentioned in Awesome Go


RabbitMQ Reconnection for Golang

Wrapper over amqp.Connection and amqp.Dial. Allowing to do a reconnection when the connection is broken before forcing the call to the Close () method to be closed

Use the default method func Dial (url string) (Conner, error) to connect to the server. You can implement your connection function and pass it to rmqconn.Open("", customFunc)

Getting started

1. install
go get -u github.com/sbabiv/rmqconn

Or, using dep:

dep ensure -add github.com/sbabiv/rmqconn
2. use it
conn, err := rmqconn.Open("amqp://usr:pwd@host:5672", rmqconn.Dial)
defer conn.Close()

if err != nil {

if conn.IsConnected() {
    ch, err := conn.GetChannel()
    if err != nil {
    defer ch.Close()

    err = ch.Publish("", "queueName", false, false, amqp.Publishing{
        Body: []byte("hello wolrd"),




Babiv Sergey




This section is empty.


View Source
var (
	// ErrConnectionUnavailable remote server is unavailable or network is down
	ErrConnectionUnavailable = errors.New("connection unavailable")
	// ErrClsoe connection was closed earlier
	ErrClose = errors.New("connection was closed earlier")


This section is empty.


type Conn

type Conn struct {
	// contains filtered or unexported fields

Conn connect instance

func (*Conn) Close

func (conn *Conn) Close() error

Close re-conn attempts

func (*Conn) GetChannel added in v1.1.0

func (conn *Conn) GetChannel() (*amqp.Channel, error)

func (*Conn) IsConnected added in v1.1.0

func (conn *Conn) IsConnected() bool

IsConnected return connection status

type Connecter

type Connecter interface {
	GetChannel() (*amqp.Channel, error)
	IsConnected() bool
	Close() error

Connecter interface for connection instance

func Open

func Open(url string, dial func(string) (Conner, error)) (Connecter, error)

Creates connection and trying to connect use Close method to stop connection attempts

type Conner

type Conner interface {
	Close() error
	NotifyClose(c chan *amqp.Error) chan *amqp.Error
	GetChannel() (*amqp.Channel, error)

Conner interface for wrapper Connection

func Dial

func Dial(url string) (Conner, error)

Dial function wrapper amqp.Dial For use amqp.DialConfig or amqp.DialTLS implement your func

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL