This commit is contained in:
shoopea 2019-06-28 15:23:52 +08:00
parent b98069f4ba
commit c9e9dc397b

64
mq.go
View File

@ -37,38 +37,40 @@ func (s MQSession) Open() error {
s.MQConnection.Close()
return err
}
q, err = s.MQChannel.QueueDeclare(
s.Queue, // name
false, // durable
false, // delete when unused
false, // exclusive
false, // no-wait
nil, // arguments
/*
q, err = s.MQChannel.QueueDeclare(
s.Queue, // name
false, // durable
false, // delete when unused
false, // exclusive
false, // no-wait
nil, // arguments
)
s.MQQueue = &q
logOnError(err, "Open : Failed to declare queue")
if err != nil {
s.MQChannel.Close()
s.MQConnection.Close()
return err
}
s.MQDelivery, err = s.MQChannel.Consume(
s.MQQueue.Name, // queue
"", // consumer
true, // auto-ack
false, // exclusive
false, // no-local
false, // no-wait
nil, // args
)
logOnError(err, "Open : Failed to register a consumer")
if err != nil {
s.MQChannel.Close()
s.MQConnection.Close()
return err
}
//log.Printf("Open : MQ Connected to amqp://" + s.User + ":" + s.Password + "@" + s.Host + "/" + s.Path)
)
s.MQQueue = &q
logOnError(err, "Open : Failed to declare queue")
if err != nil {
s.MQChannel.Close()
s.MQConnection.Close()
return err
}
s.MQDelivery, err = s.MQChannel.Consume(
s.MQQueue.Name, // queue
"", // consumer
true, // auto-ack
false, // exclusive
false, // no-local
false, // no-wait
nil, // args
)
logOnError(err, "Open : Failed to register a consumer")
if err != nil {
s.MQChannel.Close()
s.MQConnection.Close()
return err
}
//log.Printf("Open : MQ Connected to amqp://" + s.User + ":" + s.Password + "@" + s.Host + "/" + s.Path)
*/
s.isConnected = true
return nil
}