test
This commit is contained in:
parent
362800da22
commit
37945c5b60
45
workers.go
45
workers.go
@ -168,20 +168,39 @@ func MQKeepAliveWorker() {
|
||||
k := v.(*MQKeepAlive)
|
||||
k.Date = x.Date
|
||||
} else {
|
||||
clt := MQClient{}
|
||||
clt.Connection, err = amqp.Dial("amqp://" + cfg.Rabbit.User + ":" + cfg.Rabbit.Password + "@" + cfg.Rabbit.Host + "/" + x.Queue)
|
||||
clt := MQClient{
|
||||
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")
|
||||
clt.Channel, err = clt.Connection.Channel()
|
||||
logOnError(err, "MQKeepAliveWorker : Failed to open a channel")
|
||||
clt.Queue, err = clt.Channel.QueueDeclare(
|
||||
"msg", // name
|
||||
false, // durable
|
||||
false, // delete when unused
|
||||
false, // exclusive
|
||||
false, // no-wait
|
||||
nil, // arguments
|
||||
)
|
||||
logOnError(err, "MQKeepAliveWorker : Failed to declare a queue")
|
||||
if err != nil {
|
||||
clt.Connection.Close()
|
||||
} else {
|
||||
clt.Channel, err = clt.Connection.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(
|
||||
"msg", // name
|
||||
false, // durable
|
||||
false, // delete when unused
|
||||
false, // exclusive
|
||||
false, // no-wait
|
||||
nil, // arguments
|
||||
)
|
||||
logOnError(err, "MQKeepAliveWorker : Failed to declare a queue")
|
||||
if err != nil {
|
||||
clt.Channel.Close()
|
||||
clt.Connection.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
clientsKeepAlive.Store(x.UserID64, &x)
|
||||
clientsQueue[x.UserID64] = &clt
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user