test
This commit is contained in:
parent
27825e2a44
commit
ddf0207ae3
2
def.go
2
def.go
@ -28,7 +28,7 @@ type MQSession struct {
|
||||
Queue string
|
||||
MQConnection *amqp.Connection
|
||||
MQChannel *amqp.Channel
|
||||
MQQueue amqp.Queue
|
||||
MQQueue *amqp.Queue
|
||||
MQDelivery <-chan amqp.Delivery
|
||||
isConnected bool
|
||||
}
|
||||
|
9
mq.go
9
mq.go
@ -14,7 +14,8 @@ func (s MQSession) Open() error {
|
||||
}
|
||||
|
||||
if s.SSL == false {
|
||||
s.MQConnection, err = amqp.Dial("amqp://" + s.User + ":" + s.Password + "@" + s.Host + "/" + s.Path)
|
||||
conn, err := amqp.Dial("amqp://" + s.User + ":" + s.Password + "@" + s.Host + "/" + s.Path)
|
||||
s.MQConnection = conn
|
||||
} else {
|
||||
return errors.New("SSL connection not implemented")
|
||||
}
|
||||
@ -23,14 +24,15 @@ func (s MQSession) Open() error {
|
||||
s.MQConnection.Close()
|
||||
return err
|
||||
}
|
||||
s.MQChannel, err = s.MQConnection.Channel()
|
||||
ch, err := s.MQConnection.Channel()
|
||||
s.MQChannel = ch
|
||||
logOnError(err, "Open : Failed to open channel")
|
||||
if err != nil {
|
||||
s.MQChannel.Close()
|
||||
s.MQConnection.Close()
|
||||
return err
|
||||
}
|
||||
s.MQQueue, err = s.MQChannel.QueueDeclare(
|
||||
q, err := s.MQChannel.QueueDeclare(
|
||||
s.Queue, // name
|
||||
false, // durable
|
||||
false, // delete when unused
|
||||
@ -39,6 +41,7 @@ func (s MQSession) Open() error {
|
||||
nil, // arguments
|
||||
|
||||
)
|
||||
s.MQQueue = q
|
||||
logOnError(err, "Open : Failed to declare queue")
|
||||
if err != nil {
|
||||
s.MQChannel.Close()
|
||||
|
Loading…
Reference in New Issue
Block a user