Revert "test"

This reverts commit ddf0207ae3.
This commit is contained in:
shoopea 2019-06-28 15:56:22 +08:00
parent 212a9c3a2a
commit 2eb211d876
2 changed files with 4 additions and 7 deletions

2
def.go
View File

@ -28,7 +28,7 @@ type MQSession struct {
Queue string Queue string
MQConnection *amqp.Connection MQConnection *amqp.Connection
MQChannel *amqp.Channel MQChannel *amqp.Channel
MQQueue *amqp.Queue MQQueue amqp.Queue
MQDelivery <-chan amqp.Delivery MQDelivery <-chan amqp.Delivery
isConnected bool isConnected bool
} }

9
mq.go
View File

@ -14,8 +14,7 @@ func (s MQSession) Open() error {
} }
if s.SSL == false { if s.SSL == false {
conn, err := amqp.Dial("amqp://" + s.User + ":" + s.Password + "@" + s.Host + "/" + s.Path) s.MQConnection, err = amqp.Dial("amqp://" + s.User + ":" + s.Password + "@" + s.Host + "/" + s.Path)
s.MQConnection = conn
} else { } else {
return errors.New("SSL connection not implemented") return errors.New("SSL connection not implemented")
} }
@ -24,15 +23,14 @@ func (s MQSession) Open() error {
s.MQConnection.Close() s.MQConnection.Close()
return err return err
} }
ch, err := s.MQConnection.Channel() s.MQChannel, err = s.MQConnection.Channel()
s.MQChannel = ch
logOnError(err, "Open : Failed to open channel") logOnError(err, "Open : Failed to open channel")
if err != nil { if err != nil {
s.MQChannel.Close() s.MQChannel.Close()
s.MQConnection.Close() s.MQConnection.Close()
return err return err
} }
q, err := s.MQChannel.QueueDeclare( s.MQQueue, err = s.MQChannel.QueueDeclare(
s.Queue, // name s.Queue, // name
false, // durable false, // durable
false, // delete when unused false, // delete when unused
@ -41,7 +39,6 @@ func (s MQSession) Open() error {
nil, // arguments nil, // arguments
) )
s.MQQueue = q
logOnError(err, "Open : Failed to declare queue") logOnError(err, "Open : Failed to declare queue")
if err != nil { if err != nil {
s.MQChannel.Close() s.MQChannel.Close()