test
This commit is contained in:
parent
362800da22
commit
37945c5b60
23
workers.go
23
workers.go
@ -168,11 +168,24 @@ func MQKeepAliveWorker() {
|
|||||||
k := v.(*MQKeepAlive)
|
k := v.(*MQKeepAlive)
|
||||||
k.Date = x.Date
|
k.Date = x.Date
|
||||||
} else {
|
} else {
|
||||||
clt := MQClient{}
|
clt := MQClient{
|
||||||
clt.Connection, err = amqp.Dial("amqp://" + cfg.Rabbit.User + ":" + cfg.Rabbit.Password + "@" + cfg.Rabbit.Host + "/" + x.Queue)
|
User: cfg.Rabbit.User,
|
||||||
|
Password: cfg.Rabbit.Password,
|
||||||
|
Host: cfg.Rabbit.Host,
|
||||||
|
Path: x.Queue,
|
||||||
|
SSL: false,
|
||||||
|
}
|
||||||
|
clt.Connection, err = amqp.Dial("amqp://" + c.User + ":" + c.Password + "@" + c.Host + "/" + c.Path)
|
||||||
logOnError(err, "MQKeepAliveWorker : Failed to connect to RabbitMQ")
|
logOnError(err, "MQKeepAliveWorker : Failed to connect to RabbitMQ")
|
||||||
|
if err != nil {
|
||||||
|
clt.Connection.Close()
|
||||||
|
} else {
|
||||||
clt.Channel, err = clt.Connection.Channel()
|
clt.Channel, err = clt.Connection.Channel()
|
||||||
logOnError(err, "MQKeepAliveWorker : Failed to open a channel")
|
logOnError(err, "MQKeepAliveWorker : Failed to open a channel")
|
||||||
|
if err != nil {
|
||||||
|
clt.Channel.Close()
|
||||||
|
clt.Connection.Close()
|
||||||
|
} else {
|
||||||
clt.Queue, err = clt.Channel.QueueDeclare(
|
clt.Queue, err = clt.Channel.QueueDeclare(
|
||||||
"msg", // name
|
"msg", // name
|
||||||
false, // durable
|
false, // durable
|
||||||
@ -182,6 +195,12 @@ func MQKeepAliveWorker() {
|
|||||||
nil, // arguments
|
nil, // arguments
|
||||||
)
|
)
|
||||||
logOnError(err, "MQKeepAliveWorker : Failed to declare a queue")
|
logOnError(err, "MQKeepAliveWorker : Failed to declare a queue")
|
||||||
|
if err != nil {
|
||||||
|
clt.Channel.Close()
|
||||||
|
clt.Connection.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
clientsKeepAlive.Store(x.UserID64, &x)
|
clientsKeepAlive.Store(x.UserID64, &x)
|
||||||
clientsQueue[x.UserID64] = &clt
|
clientsQueue[x.UserID64] = &clt
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user