func (ch *Channel) Consume(queue, consumer string, autoAck, exclusive, noLocal, noWait bool, args amqp.Table) (<-chan amqp.Delivery, error) {
	deliveries := make(chan amqp.Delivery)
	go func() {
		for {
			d, err := ch.Channel.Consume(queue, consumer, autoAck, exclusive, noLocal, noWait, args)
			if err != nil {
				debugf("consume failed, err: %v", err)
				time.Sleep(delay * time.Second)
				continue
			}
			for msg := range d {
				deliveries <- msg
			}
			time.Sleep(delay * time.Second)
			if ch.IsClosed() {
				break
			}
		}
	}()
	return deliveries, nil
}
Consume wrap amqp.Channel.Consume, the returned delivery will end only when channel closed by developer
package rabbitmq
import (
	"time"
	"sync/atomic"
	"github.com/streadway/amqp"
)
const delay = 3  
type Connection struct {
	*amqp.Connection
}
func (c *Connection) Channel() (*Channel, error) {
	ch, err := c.Connection.Channel()
	if err != nil {
		return nil, err
	}
	channel := &Channel{
		Channel: ch,
	}
	go func() {
		for {
			reason, ok := <-channel.Channel.NotifyClose(make(chan *amqp.Error))
			if !ok || channel.IsClosed() {
				debug("channel closed")
				channel.Close()  
				break
			}
			debug("channel closed, reason: %v", reason)
			for {
				time.Sleep(delay * time.Second)
				ch, err := c.Connection.Channel()
				if err == nil {
					debug("channel recreate success")
					channel.Channel = ch
					break
				}
				debugf("channel recreate failed, err: %v", err)
			}
		}
	}()
	return channel, nil
}
func Dial(url string) (*Connection, error) {
	conn, err := amqp.Dial(url)
	if err != nil {
		return nil, err
	}
	connection := &Connection{
		Connection: conn,
	}
	go func() {
		for {
			reason, ok := <-connection.Connection.NotifyClose(make(chan *amqp.Error))
			if !ok {
				debug("connection closed")
				break
			}
			debugf("connection closed, reason: %v", reason)
			for {
				time.Sleep(delay * time.Second)
				conn, err := amqp.Dial(url)
				if err == nil {
					connection.Connection = conn
					debugf("reconnect success")
					break
				}
				debugf("reconnect failed, err: %v", err)
			}
		}
	}()
	return connection, nil
}
type Channel struct {
	*amqp.Channel
	closed int32
}
func (ch *Channel) IsClosed() bool {
	return (atomic.LoadInt32(&ch.closed) == 1)
}
func (ch *Channel) Close() error {
	if ch.IsClosed() {
		return amqp.ErrClosed
	}
	atomic.StoreInt32(&ch.closed, 1)
	return ch.Channel.Close()
}