Skip to content

Commit

Permalink
fix consumer stopped consuming when panic in consumeListener (#910)
Browse files Browse the repository at this point in the history
Co-authored-by: dengzhiwen1 <[email protected]>
  • Loading branch information
cserwen and dengzhiwen1 authored Sep 1, 2022
1 parent 3f06d9a commit a343f1b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions consumer/push_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1038,15 +1038,23 @@ func (pc *pushConsumer) consumeMessageCurrently(pq *processQueue, mq *primitive.
}

go primitive.WithRecover(func() {
defer func() {
if err := recover(); err != nil {
rlog.Error("consumeMessageCurrently panic", map[string]interface{}{
rlog.LogKeyUnderlayError: err,
rlog.LogKeyConsumerGroup: pc.consumerGroup,
})
}
if !limiterOn {
<-pc.crCh
}
}()
RETRY:
if pq.IsDroppd() {
rlog.Info("the message queue not be able to consume, because it was dropped", map[string]interface{}{
rlog.LogKeyMessageQueue: mq.String(),
rlog.LogKeyConsumerGroup: pc.consumerGroup,
})
if !limiterOn {
<-pc.crCh
}
return
}

Expand Down Expand Up @@ -1126,9 +1134,6 @@ func (pc *pushConsumer) consumeMessageCurrently(pq *processQueue, mq *primitive.
"message": subMsgs,
})
}
if !limiterOn {
<-pc.crCh
}
})
}
}
Expand Down

0 comments on commit a343f1b

Please sign in to comment.