You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by ji...@apache.org on 2023/02/05 09:05:05 UTC

[rocketmq-spring] branch master updated: [ISSUE #522] format code and Optimization description (#522)

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

jinrongtong 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 f312095  [ISSUE #522] format code and  Optimization description (#522)
f312095 is described below

commit f31209504b364ee933bd443b960bd9d7b71c860f
Author: 刘亚洲 <22...@qq.com>
AuthorDate: Sun Feb 5 17:04:59 2023 +0800

    [ISSUE #522] format code and  Optimization description (#522)
    
    * format code
    
    * Optimization description
    
    * format code
    
    ---------
    
    Co-authored-by: liuyazhou <li...@yonyou.com>
---
 .../samples/springboot/ProducerApplication.java         | 17 ++++++++++++-----
 .../autoconfigure/ExtConsumerResetConfiguration.java    |  2 +-
 .../autoconfigure/RocketMQTransactionConfiguration.java |  6 ++++--
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/rocketmq-spring-boot-samples/rocketmq-produce-demo/src/main/java/org/apache/rocketmq/samples/springboot/ProducerApplication.java b/rocketmq-spring-boot-samples/rocketmq-produce-demo/src/main/java/org/apache/rocketmq/samples/springboot/ProducerApplication.java
index 3acd8a6..9fd3ac6 100644
--- a/rocketmq-spring-boot-samples/rocketmq-produce-demo/src/main/java/org/apache/rocketmq/samples/springboot/ProducerApplication.java
+++ b/rocketmq-spring-boot-samples/rocketmq-produce-demo/src/main/java/org/apache/rocketmq/samples/springboot/ProducerApplication.java
@@ -115,7 +115,8 @@ public class ProducerApplication implements CommandLineRunner {
         });
 
         // Send message with special tag
-        rocketMQTemplate.convertAndSend(msgExtTopic + ":tag0", "I'm from tag0");  // tag0 will not be consumer-selected
+        // tag0 will not be consumer-selected
+        rocketMQTemplate.convertAndSend(msgExtTopic + ":tag0", "I'm from tag0");
         System.out.printf("syncSend topic %s tag %s %n", msgExtTopic, "tag0");
         rocketMQTemplate.convertAndSend(msgExtTopic + ":tag1", "I'm from tag1");
         System.out.printf("syncSend topic %s tag %s %n", msgExtTopic, "tag1");
@@ -144,6 +145,7 @@ public class ProducerApplication implements CommandLineRunner {
         User requestUser = new User().setUserAge((byte) 9).setUserName("requestUserName");
         User replyUser = rocketMQTemplate.sendAndReceive(objectRequestTopic, requestUser, User.class, "order-id");
         System.out.printf("send %s and receive %s %n", requestUser, replyUser);
+
         // Send request in sync mode with timeout and delayLevel parameter parameter and receive a reply of generic type.
         ProductWithPayload<String> replyGenericObject = rocketMQTemplate.sendAndReceive(genericRequestTopic, "request generic",
             new TypeReference<ProductWithPayload<String>>() {
@@ -152,21 +154,26 @@ public class ProducerApplication implements CommandLineRunner {
 
         // Send request in async mode and receive a reply of String type.
         rocketMQTemplate.sendAndReceive(stringRequestTopic, "request string", new RocketMQLocalRequestCallback<String>() {
-            @Override public void onSuccess(String message) {
+            @Override
+            public void onSuccess(String message) {
                 System.out.printf("send %s and receive %s %n", "request string", message);
             }
 
-            @Override public void onException(Throwable e) {
+            @Override
+            public void onException(Throwable e) {
                 e.printStackTrace();
             }
         });
+
         // Send request in async mode and receive a reply of User type.
         rocketMQTemplate.sendAndReceive(objectRequestTopic, new User().setUserAge((byte) 9).setUserName("requestUserName"), new RocketMQLocalRequestCallback<User>() {
-            @Override public void onSuccess(User message) {
+            @Override
+            public void onSuccess(User message) {
                 System.out.printf("send user object and receive %s %n", message.toString());
             }
 
-            @Override public void onException(Throwable e) {
+            @Override
+            public void onException(Throwable e) {
                 e.printStackTrace();
             }
         }, 5000);
diff --git a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/autoconfigure/ExtConsumerResetConfiguration.java b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/autoconfigure/ExtConsumerResetConfiguration.java
index d91af62..178285d 100644
--- a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/autoconfigure/ExtConsumerResetConfiguration.java
+++ b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/autoconfigure/ExtConsumerResetConfiguration.java
@@ -124,7 +124,7 @@ public class ExtConsumerResetConfiguration implements ApplicationContextAware, S
         String ak = resolvePlaceholders(annotation.accessKey(), consumerConfig.getAccessKey());
         String sk = resolvePlaceholders(annotation.secretKey(), consumerConfig.getSecretKey());
         int pullBatchSize = annotation.pullBatchSize();
-        //if String is not is equal "true" TLS mode will represent the as default value false
+        //If the string is not equal to "true", the TLS mode will be represented as the default value of false
         boolean useTLS = new Boolean(environment.resolvePlaceholders(annotation.tlsEnable()));
         DefaultLitePullConsumer litePullConsumer = RocketMQUtil.createDefaultLitePullConsumer(nameServer, accessChannel,
                 groupName, topicName, messageModel, selectorType, selectorExpression, ak, sk, pullBatchSize, useTLS);
diff --git a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/autoconfigure/RocketMQTransactionConfiguration.java b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/autoconfigure/RocketMQTransactionConfiguration.java
index 99c08f2..2cf6591 100644
--- a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/autoconfigure/RocketMQTransactionConfiguration.java
+++ b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/autoconfigure/RocketMQTransactionConfiguration.java
@@ -44,11 +44,13 @@ public class RocketMQTransactionConfiguration implements ApplicationContextAware
 
     private ConfigurableApplicationContext applicationContext;
 
-    @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
         this.applicationContext = (ConfigurableApplicationContext) applicationContext;
     }
 
-    @Override public void afterSingletonsInstantiated() {
+    @Override
+    public void afterSingletonsInstantiated() {
         Map<String, Object> beans = this.applicationContext.getBeansWithAnnotation(RocketMQTransactionListener.class)
             .entrySet().stream().filter(entry -> !ScopedProxyUtils.isScopedTarget(entry.getKey()))
             .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));