You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "ZhXZhao (via GitHub)" <gi...@apache.org> on 2024/03/22 11:06:43 UTC
[I] [Enhancement] java sdk SimpleConsumerExample示例代码增加对receive方法的异常捕获 [rocketmq-clients]
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: commits-unsubscribe@rocketmq.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Enhancement] java sdk SimpleConsumerExample示例代码增加对receive方法的异常捕获 [rocketmq-clients]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #715: [Enhancement] java sdk SimpleConsumerExample示例代码增加对receive方法的异常捕获
URL: https://github.com/apache/rocketmq-clients/issues/715
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Enhancement] java sdk SimpleConsumerExample示例代码增加对receive方法的异常捕获 [rocketmq-clients]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #715:
URL: https://github.com/apache/rocketmq-clients/issues/715#issuecomment-2076083523
This issue was closed because it has been inactive for 3 days since being marked as stale.
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Enhancement] java sdk SimpleConsumerExample示例代码增加对receive方法的异常捕获 [rocketmq-clients]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #715:
URL: https://github.com/apache/rocketmq-clients/issues/715#issuecomment-2068282205
This issue is stale because it has been open for 30 days with no activity. It will be closed in 3 days if no further activity occurs.
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org