Skip to content

Commit

Permalink
[ISSUE #705] Fix future in async send not complete
Browse files Browse the repository at this point in the history
  • Loading branch information
qianye1001 authored Feb 13, 2025
1 parent 1be808d commit 11aa3af
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,24 @@ public CompletableFuture<SendReceipt> asyncSend(String destination, Message<?> m
throw new IllegalArgumentException("`message` and `message.payload` cannot be null");
}
Producer grpcProducer = this.getProducer();
CompletableFuture<SendReceipt> future0;
try {
org.apache.rocketmq.client.apis.message.Message rocketMsg = this.createRocketMQMessage(destination, message, messageDelayTime, messageGroup);
future = grpcProducer.sendAsync(rocketMsg);
future0 = grpcProducer.sendAsync(rocketMsg);
if (null != future) {
future0.whenComplete((sendReceipt, throwable) -> {
if (null != throwable) {
future.completeExceptionally(throwable);
} else {
future.complete(sendReceipt);
}
});
}
} catch (Exception e) {
log.error("send request message failed. destination:{}, message:{} ", destination, message);
throw new MessagingException(e.getMessage(), e);
}
return future;
return future0;
}

public Pair<SendReceipt, Transaction> sendMessageInTransaction(String destination, Object payload) throws ClientException {
Expand Down

0 comments on commit 11aa3af

Please sign in to comment.