rabbitmq

package module
v0.0.0-...-4e4a964 Latest Latest
Warning

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

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

README

streadway/amqp Conneciton/Channel auto reconnect wrap

streadway/amqp Connection/Channel does not reconnect if rabbitmq server restart/down.

To simply developers, here is auto reconnect wrap with detail comments.

How to change existing code

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

Example

Close by developer

go run example/close/demo.go

Auto reconnect

go run example/reconnect/demo.go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool

Debug debug log flag

Functions

This section is empty.

Types

type Channel

type Channel struct {
	*amqp.Channel
	// contains filtered or unexported fields
}

Channel amqp.Channel wapper

func (*Channel) Close

func (ch *Channel) Close() error

Close ensure closed flag set

func (*Channel) Consume

func (ch *Channel) Consume(queue, consumer string, autoAck, exclusive, noLocal, noWait bool, args amqp.Table) (<-chan amqp.Delivery, error)

Consume warp amqp.Channel.Consume, the returned delivery will end only when channel closed by developer

func (*Channel) IsClosed

func (ch *Channel) IsClosed() bool

IsClosed indicate closed by developer

type Connection

type Connection struct {
	*amqp.Connection
	// contains filtered or unexported fields
}

Connection amqp.Connection wrapper

func Dial

func Dial(url string) (*Connection, error)

func DialWithCallBackChan

func DialWithCallBackChan(url string, cbChannel chan bool) (*Connection, error)

Dial wrap amqp.Dial, dial and get a reconnect connection

func (*Connection) Channel

func (c *Connection) Channel() (*Channel, error)

Channel wrap amqp.Connection.Channel, get a auto reconnect channel

Jump to

Keyboard shortcuts

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