test
This commit is contained in:
parent
1ca4769504
commit
5c6a38c7b9
11
workers.go
11
workers.go
@ -175,7 +175,7 @@ func MQKeepAliveWorker() {
|
|||||||
Path: x.Queue,
|
Path: x.Queue,
|
||||||
SSL: false,
|
SSL: false,
|
||||||
}
|
}
|
||||||
clt.Connection, err = amqp.Dial("amqp://" + c.User + ":" + c.Password + "@" + c.Host + "/" + c.Path)
|
clt.Connection, err = amqp.Dial("amqp://" + clt.User + ":" + clt.Password + "@" + clt.Host + "/" + clt.Path)
|
||||||
logOnError(err, "MQKeepAliveWorker : Failed to connect to RabbitMQ")
|
logOnError(err, "MQKeepAliveWorker : Failed to connect to RabbitMQ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
clt.Connection.Close()
|
clt.Connection.Close()
|
||||||
@ -236,7 +236,7 @@ func MQTGCmdWorker(id int, cmds <-chan TGCommand) {
|
|||||||
if _, ok := clientsKeepAlive.Load(c.FromUserID64); ok {
|
if _, ok := clientsKeepAlive.Load(c.FromUserID64); ok {
|
||||||
j, err := json.Marshal(c)
|
j, err := json.Marshal(c)
|
||||||
logOnError(err, "MQTGCmdWorker["+strconv.Itoa(id)+"] : Marshal(c)")
|
logOnError(err, "MQTGCmdWorker["+strconv.Itoa(id)+"] : Marshal(c)")
|
||||||
//log.Printf("MQTGCmdWorker["+strconv.Itoa(id)+"] : new command.\n%s\n", string(j))
|
log.Printf("MQTGCmdWorker["+strconv.Itoa(id)+"] : new command.\n%s\n", string(j))
|
||||||
for clientsQueue[c.FromUserID64].Connection.IsClosed() {
|
for clientsQueue[c.FromUserID64].Connection.IsClosed() {
|
||||||
log.Printf("MQKeepAliveWorker : Resetting MQ connection for #%d.\n", c.FromUserID64)
|
log.Printf("MQKeepAliveWorker : Resetting MQ connection for #%d.\n", c.FromUserID64)
|
||||||
clientsQueue[c.FromUserID64].Connection, err = amqp.Dial("amqp://" + clientsQueue[c.FromUserID64].User + ":" + clientsQueue[c.FromUserID64].Password + "@" + clientsQueue[c.FromUserID64].Host + "/" + clientsQueue[c.FromUserID64].Path)
|
clientsQueue[c.FromUserID64].Connection, err = amqp.Dial("amqp://" + clientsQueue[c.FromUserID64].User + ":" + clientsQueue[c.FromUserID64].Password + "@" + clientsQueue[c.FromUserID64].Host + "/" + clientsQueue[c.FromUserID64].Path)
|
||||||
@ -274,15 +274,16 @@ func MQTGCmdWorker(id int, cmds <-chan TGCommand) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
err = clientsQueue[c.FromUserID64].Channel.Publish(
|
err = clientsQueue[c.FromUserID64].Channel.Publish(
|
||||||
"", // exchange
|
"", // exchange
|
||||||
clientsQueue[c.FromUserID64].Queue.Name, // routing key
|
clientsQueue[c.FromUserID64].Queue.Name, // routing key
|
||||||
false, // mandatory
|
false, // mandatory
|
||||||
false, // immediate
|
false, // immediate
|
||||||
amqp.Publishing{
|
amqp.Publishing{
|
||||||
ContentType: "application/json",
|
ContentType: "application/json",
|
||||||
Body: []byte(j),
|
Body: []byte(j),
|
||||||
})
|
})
|
||||||
logOnError(err, "MQTGCmdWorker["+strconv.Itoa(id)+"] : Publishing message.")
|
logOnError(err, "MQTGCmdWorker["+strconv.Itoa(id)+"] : Publishing message.")
|
||||||
|
log.Printf("MQTGCmdWorker[" + strconv.Itoa(id) + "] : Message published.")
|
||||||
} else {
|
} else {
|
||||||
log.Printf("MQTGCmdWorker["+strconv.Itoa(id)+"] : client %d offline.\n", c.FromUserID64)
|
log.Printf("MQTGCmdWorker["+strconv.Itoa(id)+"] : client %d offline.\n", c.FromUserID64)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user