You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by di...@apache.org on 2025/03/13 07:51:44 UTC

(rocketmq-spring) branch master updated: Remove unnecessary catch blocks and log statements in syncSendGrpcMessage (#711)

This is an automated email from the ASF dual-hosted git repository.

dinglei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-spring.git


The following commit(s) were added to refs/heads/master by this push:
     new 26939d0  Remove unnecessary catch blocks and log statements in syncSendGrpcMessage (#711)
26939d0 is described below

commit 26939d03c67b5c5a1da0459a66b7e38ee940add8
Author: rongtong <ji...@163.com>
AuthorDate: Thu Mar 13 15:51:39 2025 +0800

    Remove unnecessary catch blocks and log statements in syncSendGrpcMessage (#711)
    
    * Remove unnecessary catch blocks and log statements.
    
    * Optimize log output
    
    * Optimize log output
---
 .../rocketmq/client/core/RocketMQClientTemplate.java      | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/core/RocketMQClientTemplate.java b/rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/core/RocketMQClientTemplate.java
index 25f94ca..4213cb4 100644
--- a/rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/core/RocketMQClientTemplate.java
+++ b/rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/core/RocketMQClientTemplate.java
@@ -221,24 +221,16 @@ public class RocketMQClientTemplate extends AbstractMessageSendingTemplate<Strin
      */
     public SendReceipt syncSendGrpcMessage(String destination, Message<?> message, Duration messageDelayTime, String messageGroup) {
         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");
         }
         SendReceipt sendReceipt = null;
         try {
             org.apache.rocketmq.client.apis.message.Message rocketMsg = this.createRocketMQMessage(destination, message, messageDelayTime, messageGroup);
             Producer grpcProducer = this.getProducer();
-            try {
-                sendReceipt = grpcProducer.send(rocketMsg);
-                log.info("Send message successfully, messageId={}", sendReceipt.getMessageId());
-            } catch (Throwable t) {
-                log.error("Failed to send message", t);
-            }
+            return grpcProducer.send(rocketMsg);
         } catch (Exception e) {
-            log.error("send request message failed. destination:{}, message:{} ", destination, message);
             throw new MessagingException(e.getMessage(), e);
         }
-        return sendReceipt;
     }
 
 
@@ -311,7 +303,6 @@ public class RocketMQClientTemplate extends AbstractMessageSendingTemplate<Strin
 
     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();
@@ -329,7 +320,6 @@ public class RocketMQClientTemplate extends AbstractMessageSendingTemplate<Strin
                 });
             }
         } catch (Exception e) {
-            log.error("send request message failed. destination:{}, message:{} ", destination, message);
             throw new MessagingException(e.getMessage(), e);
         }
         return future0;
@@ -358,7 +348,6 @@ public class RocketMQClientTemplate extends AbstractMessageSendingTemplate<Strin
      */
     public Pair<SendReceipt, Transaction> sendTransactionMessage(String destination, Message<?> message) {
         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");
         }
         final SendReceipt sendReceipt;
@@ -368,9 +357,7 @@ public class RocketMQClientTemplate extends AbstractMessageSendingTemplate<Strin
         try {
             transaction = grpcProducer.beginTransaction();
             sendReceipt = grpcProducer.send(rocketMsg, transaction);
-            log.info("Send transaction message successfully, messageId={}", sendReceipt.getMessageId());
         } catch (ClientException e) {
-            log.error("send request message failed. destination:{}, message:{} ", destination, message);
             throw new RuntimeException(e);
         }
         return new Pair<>(sendReceipt, transaction);