Skip to content

Commit 94e1241

Browse files
committed
Optimize log output
1 parent ee21b1b commit 94e1241

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/autoconfigure/ExtConsumerResetConfiguration.java

+12-11
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import java.util.Objects;
4848
import java.util.stream.Collectors;
4949

50-
5150
@Configuration
5251
public class ExtConsumerResetConfiguration implements ApplicationContextAware, SmartInitializingSingleton {
5352
private static final Logger log = LoggerFactory.getLogger(ExtConsumerResetConfiguration.class);
@@ -61,7 +60,7 @@ public class ExtConsumerResetConfiguration implements ApplicationContextAware, S
6160
private RocketMQMessageConverter rocketMQMessageConverter;
6261

6362
public ExtConsumerResetConfiguration(RocketMQMessageConverter rocketMQMessageConverter,
64-
ConfigurableEnvironment environment, RocketMQProperties rocketMQProperties) {
63+
ConfigurableEnvironment environment, RocketMQProperties rocketMQProperties) {
6564
this.rocketMQMessageConverter = rocketMQMessageConverter;
6665
this.environment = environment;
6766
this.rocketMQProperties = rocketMQProperties;
@@ -75,9 +74,9 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
7574
@Override
7675
public void afterSingletonsInstantiated() {
7776
Map<String, Object> beans = this.applicationContext
78-
.getBeansWithAnnotation(org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration.class)
79-
.entrySet().stream().filter(entry -> !ScopedProxyUtils.isScopedTarget(entry.getKey()))
80-
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
77+
.getBeansWithAnnotation(org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration.class)
78+
.entrySet().stream().filter(entry -> !ScopedProxyUtils.isScopedTarget(entry.getKey()))
79+
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
8180
beans.forEach(this::registerTemplate);
8281
}
8382

@@ -103,10 +102,12 @@ private void registerTemplate(String beanName, Object bean) {
103102
rocketMQTemplate.setSimpleConsumerBuilder(consumerBuilder);
104103
rocketMQTemplate.setSimpleConsumer(simpleConsumer);
105104
rocketMQTemplate.setMessageConverter(rocketMQMessageConverter.getMessageConverter());
106-
log.info("Set real simpleConsumer to :{} {}", beanName, annotation.value());
105+
String topic = environment.resolvePlaceholders(annotation.topic());
106+
log.info("Set real simpleConsumer to {} using {} topic", beanName, topic);
107107
}
108108

109-
private SimpleConsumerBuilder createConsumer(org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration annotation) {
109+
private SimpleConsumerBuilder createConsumer(
110+
org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration annotation) {
110111
RocketMQProperties.SimpleConsumer simpleConsumer = rocketMQProperties.getSimpleConsumer();
111112
String consumerGroupName = resolvePlaceholders(annotation.consumerGroup(), simpleConsumer.getConsumerGroup());
112113
String topicName = resolvePlaceholders(annotation.topic(), simpleConsumer.getTopic());
@@ -142,12 +143,12 @@ private String resolvePlaceholders(String text, String defaultValue) {
142143
}
143144

144145
private void validate(org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration annotation,
145-
GenericApplicationContext genericApplicationContext) {
146+
GenericApplicationContext genericApplicationContext) {
146147
if (genericApplicationContext.isBeanNameInUse(annotation.value())) {
147148
throw new BeanDefinitionValidationException(
148-
String.format("Bean {} has been used in Spring Application Context, " +
149-
"please check the @ExtRocketMQConsumerConfiguration",
150-
annotation.value()));
149+
String.format("Bean {} has been used in Spring Application Context, " +
150+
"please check the @ExtRocketMQConsumerConfiguration",
151+
annotation.value()));
151152
}
152153
}
153154
}

rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/autoconfigure/ExtTemplateResetConfiguration.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ private void registerTemplate(String beanName, Object bean) {
9494
RocketMQClientTemplate rocketMQTemplate = (RocketMQClientTemplate) bean;
9595
rocketMQTemplate.setProducerBuilder(producerBuilder);
9696
rocketMQTemplate.setMessageConverter(rocketMQMessageConverter.getMessageConverter());
97-
log.info("Set real producerBuilder to :{} {}", beanName, annotation.value());
97+
String topic = environment.resolvePlaceholders(annotation.topic());
98+
log.info("Set real producer to {} using topic {}", beanName, topic);
9899
}
99100

100101
private ProducerBuilder createProducer(ExtProducerResetConfiguration annotation) {

0 commit comments

Comments
 (0)