From 0f30a2d37dfcd3f20d1d9a4f2079c3da4026ab8c Mon Sep 17 00:00:00 2001 From: liuyazhou Date: Sun, 5 Feb 2023 01:17:57 +0800 Subject: [PATCH 1/3] format code --- .../samples/springboot/ProducerApplication.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 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 3acd8a68..9fd3ac60 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 void onException(Throwable var1) { }); // 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 void onException(Throwable var1) { 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 replyGenericObject = rocketMQTemplate.sendAndReceive(genericRequestTopic, "request generic", new TypeReference>() { @@ -152,21 +154,26 @@ public void onException(Throwable var1) { // Send request in async mode and receive a reply of String type. rocketMQTemplate.sendAndReceive(stringRequestTopic, "request string", new RocketMQLocalRequestCallback() { - @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() { - @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); From 0094d4a1dab84ed567f96d19d59712d0a517a8e5 Mon Sep 17 00:00:00 2001 From: liuyazhou Date: Sun, 5 Feb 2023 01:37:09 +0800 Subject: [PATCH 2/3] Optimization description --- .../spring/autoconfigure/ExtConsumerResetConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d91af62e..178285d7 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 @@ private DefaultLitePullConsumer createConsumer(ExtRocketMQConsumerConfiguration 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); From 1197075bb3b895c646674a8244cefc651b4f9323 Mon Sep 17 00:00:00 2001 From: liuyazhou Date: Sun, 5 Feb 2023 01:43:06 +0800 Subject: [PATCH 3/3] format code --- .../autoconfigure/RocketMQTransactionConfiguration.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 99c08f20..2cf65913 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 beans = this.applicationContext.getBeansWithAnnotation(RocketMQTransactionListener.class) .entrySet().stream().filter(entry -> !ScopedProxyUtils.isScopedTarget(entry.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));