You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by "jevonsnotes (via GitHub)" <gi...@apache.org> on 2024/07/05 10:49:43 UTC

[D] 异步回调不起作用 [rocketmq-clients]

GitHub user jevonsnotes created a discussion: 异步回调不起作用

使用 rocketmq-v5-client-spring-boot-starter 2.3.0 进行grpc异步调用,发现传进去的入参并没有被真正使用,请问是哪里操作不正确吗?
```
SendCallback callback = sendCallback == null ? getDefaultSendCallBack() : sendCallback;
        CompletableFuture<SendReceipt> future0 = new CompletableFuture<>();
        future0.whenCompleteAsync((sendReceipt, throwable)->{
            if(throwable != null){
                callback.onException(throwable);
                return;
            }
            callback.onSuccess(sendReceipt);
        },pool);
        rocketMQTemplate.asyncSendFifoMessage(topic,message, messageGroup, future0);
```
debug进源码发现没有真正使用到入参 futrue
```
    public CompletableFuture<SendReceipt> asyncSend(String destination, Message<?> message, Duration messageDelayTime, String messageGroup, CompletableFuture<SendReceipt> future) {
        if (Objects.isNull(message) || Objects.isNull(message.getPayload())) {
            log.error("send request message failed. destination:{}, message is null ", destination);
            throw new IllegalArgumentException("`message` and `message.payload` cannot be null");
        }
        Producer grpcProducer = this.getProducer();
        try {
            org.apache.rocketmq.client.apis.message.Message rocketMsg = this.createRocketMQMessage(destination, message, messageDelayTime, messageGroup);
            future = grpcProducer.sendAsync(rocketMsg);
        } catch (Exception e) {
            log.error("send request message failed. destination:{}, message:{} ", destination, message);
            throw new MessagingException(e.getMessage(), e);
        }
        return future;
    }
```


GitHub link: https://github.com/apache/rocketmq-clients/discussions/786

----
This is an automatically sent email for dev@rocketmq.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@rocketmq.apache.org