[ Cmii ] [ Octopus ] - hot fix manual shut down init queue - 2
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user