Skip to content

Commit

Permalink
新增:异常日志打印
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Sep 23, 2023
1 parent 9d1fbb5 commit f3e48d7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rabbitConsumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func (receiver *rabbitConsumer) Subscribe(queueName string, routingKey string, p
args := receiver.createEventArgs(page)
exception.Try(func() {
consumerHandle(string(page.Body), args)
}).CatchException(func(exp any) {
_ = flog.Errorf("Subscribe exception:%s", exp)
})
}
_ = chl.Close()
Expand All @@ -72,6 +74,8 @@ func (receiver *rabbitConsumer) SubscribeAck(queueName string, routingKey string
_ = flog.Errorf("Failed to Ack %s: %s %s", queueName, err, string(page.Body))
}
}
}).CatchException(func(exp any) {
_ = flog.Errorf("SubscribeAck exception:%s", exp)
})
if !isSuccess {
// Nack
Expand Down Expand Up @@ -105,6 +109,8 @@ func (receiver *rabbitConsumer) SubscribeBatch(queueName string, routingKey stri
if lst.Count() > 0 {
exception.Try(func() {
consumerHandle(lst)
}).CatchException(func(exp any) {
_ = flog.Errorf("SubscribeBatch exception:%s", exp)
})
}
time.Sleep(500 * time.Millisecond)
Expand Down Expand Up @@ -137,6 +143,8 @@ func (receiver *rabbitConsumer) SubscribeBatchAck(queueName string, routingKey s
_ = flog.Errorf("Failed to Ack %s: %s", queueName, err)
}
}
}).CatchException(func(exp any) {
_ = flog.Errorf("SubscribeBatchAck exception:%s", exp)
})
if !isSuccess {
// Nack
Expand Down

0 comments on commit f3e48d7

Please sign in to comment.