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 f584c74  Optimize log output (#712)
f584c74 is described below

commit f584c745fd40c7d190b97e9a16347f21abd0c376
Author: rongtong <jinrongto...@163.com>
AuthorDate: Thu Mar 13 15:52:01 2025 +0800

    Optimize log output (#712)
    
    * Optimize log output
---
 .../ExtConsumerResetConfiguration.java             | 82 +++++++++++++++++-----
 .../ExtTemplateResetConfiguration.java             |  3 +-
 2 files changed, 68 insertions(+), 17 deletions(-)

diff --git 
a/rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/autoconfigure/ExtConsumerResetConfiguration.java
 
b/rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/autoconfigure/ExtConsumerResetConfiguration.java
index 6e854a0..35837c6 100644
--- 
a/rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/autoconfigure/ExtConsumerResetConfiguration.java
+++ 
b/rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/autoconfigure/ExtConsumerResetConfiguration.java
@@ -47,7 +47,6 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.stream.Collectors;
 
-
 @Configuration
 public class ExtConsumerResetConfiguration implements ApplicationContextAware, 
SmartInitializingSingleton {
     private static final Logger log = 
LoggerFactory.getLogger(ExtConsumerResetConfiguration.class);
@@ -61,7 +60,7 @@ public class ExtConsumerResetConfiguration implements 
ApplicationContextAware, S
     private RocketMQMessageConverter rocketMQMessageConverter;
 
     public ExtConsumerResetConfiguration(RocketMQMessageConverter 
rocketMQMessageConverter,
-                                         ConfigurableEnvironment environment, 
RocketMQProperties rocketMQProperties) {
+        ConfigurableEnvironment environment, RocketMQProperties 
rocketMQProperties) {
         this.rocketMQMessageConverter = rocketMQMessageConverter;
         this.environment = environment;
         this.rocketMQProperties = rocketMQProperties;
@@ -75,9 +74,9 @@ public class ExtConsumerResetConfiguration implements 
ApplicationContextAware, S
     @Override
     public void afterSingletonsInstantiated() {
         Map<String, Object> beans = this.applicationContext
-                
.getBeansWithAnnotation(org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration.class)
-                .entrySet().stream().filter(entry -> 
!ScopedProxyUtils.isScopedTarget(entry.getKey()))
-                .collect(Collectors.toMap(Map.Entry::getKey, 
Map.Entry::getValue));
+            
.getBeansWithAnnotation(org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration.class)
+            .entrySet().stream().filter(entry -> 
!ScopedProxyUtils.isScopedTarget(entry.getKey()))
+            .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
         beans.forEach(this::registerTemplate);
     }
 
@@ -93,9 +92,12 @@ public class ExtConsumerResetConfiguration implements 
ApplicationContextAware, S
 
         SimpleConsumerBuilder consumerBuilder = null;
         SimpleConsumer simpleConsumer = null;
+        SimpleConsumerInfo simpleConsumerInfo = null;
+
         try {
-            consumerBuilder = createConsumer(annotation);
-            simpleConsumer = consumerBuilder.build();
+            final ClientServiceProvider provider = 
ClientServiceProvider.loadService();
+            SimpleConsumerBuilder simpleConsumerBuilder = 
provider.newSimpleConsumerBuilder();
+            simpleConsumerInfo = createConsumer(annotation, 
simpleConsumerBuilder);
         } catch (Exception e) {
             log.error("Failed to startup SimpleConsumer for RocketMQTemplate 
{}", beanName, e);
         }
@@ -103,10 +105,12 @@ public class ExtConsumerResetConfiguration implements 
ApplicationContextAware, S
         rocketMQTemplate.setSimpleConsumerBuilder(consumerBuilder);
         rocketMQTemplate.setSimpleConsumer(simpleConsumer);
         
rocketMQTemplate.setMessageConverter(rocketMQMessageConverter.getMessageConverter());
-        log.info("Set real simpleConsumer to :{} {}", beanName, 
annotation.value());
+        log.info("Set real simpleConsumer {} to {}", simpleConsumerInfo, 
beanName);
     }
 
-    private SimpleConsumerBuilder 
createConsumer(org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration
 annotation) {
+    private SimpleConsumerInfo createConsumer(
+        org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration 
annotation,
+        SimpleConsumerBuilder simpleConsumerBuilder) {
         RocketMQProperties.SimpleConsumer simpleConsumer = 
rocketMQProperties.getSimpleConsumer();
         String consumerGroupName = 
resolvePlaceholders(annotation.consumerGroup(), 
simpleConsumer.getConsumerGroup());
         String topicName = resolvePlaceholders(annotation.topic(), 
simpleConsumer.getTopic());
@@ -121,10 +125,8 @@ public class ExtConsumerResetConfiguration implements 
ApplicationContextAware, S
         Boolean sslEnabled = simpleConsumer.isSslEnabled();
         Assert.hasText(topicName, "[topic] must not be null");
         ClientConfiguration clientConfiguration = 
RocketMQUtil.createClientConfiguration(accessKey, secretKey, endPoints, 
requestTimeout, sslEnabled, namespace);
-        final ClientServiceProvider provider = 
ClientServiceProvider.loadService();
         FilterExpression filterExpression = 
RocketMQUtil.createFilterExpression(tag, filterExpressionType);
         Duration duration = Duration.ofSeconds(awaitDuration);
-        SimpleConsumerBuilder simpleConsumerBuilder = 
provider.newSimpleConsumerBuilder();
         simpleConsumerBuilder.setClientConfiguration(clientConfiguration);
         if (StringUtils.hasLength(consumerGroupName)) {
             simpleConsumerBuilder.setConsumerGroup(consumerGroupName);
@@ -133,7 +135,8 @@ public class ExtConsumerResetConfiguration implements 
ApplicationContextAware, S
         if (Objects.nonNull(filterExpression)) {
             
simpleConsumerBuilder.setSubscriptionExpressions(Collections.singletonMap(topicName,
 filterExpression));
         }
-        return simpleConsumerBuilder;
+
+        return new SimpleConsumerInfo(consumerGroupName, topicName, endPoints, 
namespace, tag, filterExpressionType, requestTimeout, awaitDuration, 
sslEnabled);
     }
 
     private String resolvePlaceholders(String text, String defaultValue) {
@@ -142,12 +145,59 @@ public class ExtConsumerResetConfiguration implements 
ApplicationContextAware, S
     }
 
     private void 
validate(org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration 
annotation,
-                          GenericApplicationContext genericApplicationContext) 
{
+        GenericApplicationContext genericApplicationContext) {
         if (genericApplicationContext.isBeanNameInUse(annotation.value())) {
             throw new BeanDefinitionValidationException(
-                    String.format("Bean {} has been used in Spring Application 
Context, " +
-                                    "please check the 
@ExtRocketMQConsumerConfiguration",
-                            annotation.value()));
+                String.format("Bean {} has been used in Spring Application 
Context, " +
+                        "please check the @ExtRocketMQConsumerConfiguration",
+                    annotation.value()));
+        }
+    }
+
+    static class SimpleConsumerInfo {
+        String consumerGroup;
+
+        String topicName;
+
+        String endPoints;
+
+        String namespace;
+
+        String tag;
+
+        String filterExpressionType;
+
+        Duration requestTimeout;
+
+        int awaitDuration;
+
+        Boolean sslEnabled;
+
+        public SimpleConsumerInfo(String consumerGroupName, String topicName, 
String endPoints, String namespace,
+            String tag, String filterExpressionType, Duration requestTimeout, 
int awaitDuration, Boolean sslEnabled) {
+            this.consumerGroup = consumerGroupName;
+            this.topicName = topicName;
+            this.endPoints = endPoints;
+            this.namespace = namespace;
+            this.tag = tag;
+            this.filterExpressionType = filterExpressionType;
+            this.requestTimeout = requestTimeout;
+            this.awaitDuration = awaitDuration;
+            this.sslEnabled = sslEnabled;
+        }
+
+        @Override public String toString() {
+            return "SimpleConsumerInfo{" +
+                "consumerGroup='" + consumerGroup + '\'' +
+                ", topicName='" + topicName + '\'' +
+                ", endPoints='" + endPoints + '\'' +
+                ", namespace='" + namespace + '\'' +
+                ", tag='" + tag + '\'' +
+                ", filterExpressionType='" + filterExpressionType + '\'' +
+                ", requestTimeout(seconds)=" + requestTimeout.getSeconds() +
+                ", awaitDuration=" + awaitDuration +
+                ", sslEnabled=" + sslEnabled +
+                '}';
         }
     }
 }
diff --git 
a/rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/autoconfigure/ExtTemplateResetConfiguration.java
 
b/rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/autoconfigure/ExtTemplateResetConfiguration.java
index 1973752..ec6cbe6 100644
--- 
a/rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/autoconfigure/ExtTemplateResetConfiguration.java
+++ 
b/rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/autoconfigure/ExtTemplateResetConfiguration.java
@@ -94,7 +94,8 @@ public class ExtTemplateResetConfiguration implements 
ApplicationContextAware, S
         RocketMQClientTemplate rocketMQTemplate = (RocketMQClientTemplate) 
bean;
         rocketMQTemplate.setProducerBuilder(producerBuilder);
         
rocketMQTemplate.setMessageConverter(rocketMQMessageConverter.getMessageConverter());
-        log.info("Set real producerBuilder to :{} {}", beanName, 
annotation.value());
+        String topic = environment.resolvePlaceholders(annotation.topic());
+        log.info("Set real producer to {} using topic {}", beanName, topic);
     }
 
     private ProducerBuilder createProducer(ExtProducerResetConfiguration 
annotation) {

Reply via email to