支付宝 接入一系列修改
This commit is contained in:
@@ -34,13 +34,13 @@ type GameMsg struct {
|
||||
|
||||
var (
|
||||
//消息队列
|
||||
msgQueue chan GameMsg = make(chan GameMsg, 100)
|
||||
msgQueue = make(chan GameMsg, 100)
|
||||
|
||||
fileName = "ErrPushMsg"
|
||||
)
|
||||
|
||||
func init() {
|
||||
ConsumeQueue()
|
||||
go ConsumeQueue()
|
||||
}
|
||||
|
||||
// AddQueue 添加消息队列
|
||||
@@ -50,42 +50,40 @@ func AddQueue(gameMsg GameMsg) {
|
||||
|
||||
// ConsumeQueue 消费消息队列
|
||||
func ConsumeQueue() {
|
||||
go func() {
|
||||
//捕获异常
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
//TODO 捕获异常
|
||||
logUtilPlus.ErrorLog("推送充值信息到game异常 err:%s", err)
|
||||
//捕获异常
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
//TODO 捕获异常
|
||||
logUtilPlus.ErrorLog("推送充值信息到game异常 err:%s", err)
|
||||
|
||||
//重新开启
|
||||
restartConsumer()
|
||||
}
|
||||
}()
|
||||
|
||||
for {
|
||||
gameMsg := <-msgQueue
|
||||
|
||||
url := fmt.Sprintf("http://www.game.com/pay %s", gameMsg.GameId)
|
||||
|
||||
//消费消息队列 推送重置信息到game
|
||||
result, err := webUtil.GetWebData(url, map[string]string{})
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("推送充值信息到game异常 err:%s", err)
|
||||
|
||||
//放入消息队列重新推送
|
||||
if gameMsg.pushCount < 3 {
|
||||
msgQueue <- gameMsg
|
||||
gameMsg.pushCount++
|
||||
} else { //加入文件放弃推送
|
||||
WriteErrPushMsg(url)
|
||||
}
|
||||
}
|
||||
|
||||
if string(result) != "" {
|
||||
|
||||
}
|
||||
//重新开启
|
||||
restartConsumer()
|
||||
}
|
||||
}()
|
||||
|
||||
for {
|
||||
gameMsg := <-msgQueue
|
||||
|
||||
url := fmt.Sprintf("http://www.game.com/pay %s", gameMsg.GameId)
|
||||
|
||||
//消费消息队列 推送重置信息到game
|
||||
result, err := webUtil.GetWebData(url, map[string]string{})
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("推送充值信息到game异常 err:%s", err)
|
||||
|
||||
//放入消息队列重新推送
|
||||
if gameMsg.pushCount < 3 {
|
||||
msgQueue <- gameMsg
|
||||
gameMsg.pushCount++
|
||||
} else { //加入文件放弃推送
|
||||
WriteErrPushMsg(url)
|
||||
}
|
||||
}
|
||||
|
||||
if string(result) != "" {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WriteErrPushMsg 推送异常消息 写入文件
|
||||
@@ -117,7 +115,7 @@ func restartConsumer() {
|
||||
return
|
||||
}
|
||||
logUtilPlus.InfoLog("重新启动消费者,重试次数: %d", retryCount+1)
|
||||
ConsumeQueue()
|
||||
go ConsumeQueue()
|
||||
return
|
||||
}
|
||||
retryCount++
|
||||
|
||||
Reference in New Issue
Block a user