aaron-ai commented on code in PR #5755:
URL: https://github.com/apache/rocketmq/pull/5755#discussion_r1055325703
##########
broker/src/main/java/org/apache/rocketmq/broker/failover/EscapeBridge.java:
##########
@@ -283,6 +282,28 @@ public MessageExt getMessage(String topic, long offset,
int queueId, String brok
}
}
+ public CompletableFuture<MessageExt> getMessageAsync(String topic, long
offset, int queueId, String brokerName, boolean deCompressBody) {
+ MessageStore messageStore =
brokerController.getMessageStoreByBrokerName(brokerName);
+ if (messageStore != null) {
+ return messageStore.getMessageAsync(innerConsumerGroupName, topic,
queueId, offset, 1, null)
+ .thenApply(result -> {
+ if (result == null) {
+ LOG.warn("getMessageResult is null ,
innerConsumerGroupName {}, topic {}, offset {}, queueId {}",
innerConsumerGroupName, topic, offset, queueId);
+ return null;
+ }
+ List<MessageExt> list = decodeMsgList(result,
deCompressBody);
+ if (list == null || list.isEmpty()) {
+ LOG.warn("Can not get msg , topic {}, offset {},
queueId {}, result is {}", topic, offset, queueId, result);
+ return null;
+ } else {
+ return list.get(0);
Review Comment:
redundant else, maybe we could refer to [Return Early
Pattern](https://medium.com/swlh/return-early-pattern-3d18a41bba8).
--
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]