chirpnest/mq.go
2019-06-28 16:18:48 +08:00

26 lines
403 B
Go

package main
import (
"github.com/streadway/amqp"
)
func (c *MQClient) Open() error {
conn, err := amqp.Dial("amqp://" + c.User + ":" + c.Password + "@" + c.Host + "/" + c.Path)
c.Connection = conn
if err != nil {
c.Connection.Close()
return err
}
ch, err := c.Connection.Channel()
c.Channel = ch
if err != nil {
c.Channel.Close()
c.Connection.Close()
return err
}
return err
}