ZhXZhao opened a new issue, #715:
URL: https://github.com/apache/rocketmq-clients/issues/715
### Before Creating the Enhancement Request
- [X] I have confirmed that this should be classified as an enhancement
rather than a bug/feature.
### Programming Language of the Client
Java
### Summary
java sdk SimpleConsumerExample示例代码增加对receive方法的异常捕获
### Motivation
在触发服务端限流等异常事件时,receive方法会抛出异常,当限流恢复时,consumer不会自愈
### Describe the Solution You'd Like
示例代码增加对receive方法的异常捕获
```
// Receive message, multi-threading is more recommended.
do {
List<MessageView> messages = null;
try {
messages = consumer.receive(maxMessageNum,
invisibleDuration);
}catch (Throwable t) {
log.error("*****", t);
}
log.info("Received {} message(s)", messages.size());
for (MessageView message : messages) {
final MessageId messageId = message.getMessageId();
try {
consumer.ack(message);
log.info("Message is acknowledged successfully,
messageId={}", messageId);
} catch (Throwable t) {
log.error("Message is failed to be acknowledged,
messageId={}", messageId, t);
}
}
} while (true);
```
### Describe Alternatives You've Considered
None
### Additional Context
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]