[ Cmii ] [ Octopus ] - hot fix manual shut down init queue - 2

This commit is contained in:
zeaslity
2024-04-10 10:47:32 +08:00
parent 83a676e321
commit a9a9ab859e
6 changed files with 191 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/streadway/amqp"
"strings"
"sync"
"sync/atomic"
"wdd.io/agent-common/logger"
)
@@ -47,7 +48,7 @@ type RabbitQueue struct {
// 返回消息队列
ReceiveChan *RabbitReceiveChan
// Consume 是否继续
ConsumeOK bool
ConsumeOK atomic.Bool
}
// RabbitMQConn is a struct that holds the connection and channel objects
@@ -195,7 +196,7 @@ func (r *RabbitQueue) Handle() chan bool {
deliveries := r.Read(true)
// 2024年4月9日
r.ConsumeOK = true
r.ConsumeOK.Swap(true)
foreverHandle := make(chan bool)
// 死循环处理Octopus Message
@@ -215,9 +216,8 @@ func (r *RabbitQueue) Handle() chan bool {
})
// 2024年4月9日
if !r.ConsumeOK {
marshal, _ := json.Marshal(r.RabbitProp)
log.InfoF("Rabbit Queue of %s disconnect!", marshal)
if !r.ConsumeOK.Load() {
log.InfoF("Rabbit Queue of [%s] [%s[ disconnect!", r.RabbitProp.ExchangeName, r.RabbitProp.QueueName)
break
}
}