You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2018/12/18 14:40:30 UTC

[GitHub] vongosling commented on a change in pull request #6: Rationalise use of ObjectMapper

vongosling commented on a change in pull request #6: Rationalise use of ObjectMapper
URL: https://github.com/apache/rocketmq-spring/pull/6#discussion_r242562027
 
 

 ##########
 File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/config/RocketMQAutoConfiguration.java
 ##########
 @@ -18,30 +18,37 @@
 package org.apache.rocketmq.spring.config;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.rocketmq.client.MQAdmin;
 import org.apache.rocketmq.client.producer.DefaultMQProducer;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Import;
 import org.springframework.context.annotation.Role;
 import org.springframework.util.Assert;
 
-import java.util.Objects;
-
 @Configuration
 @EnableConfigurationProperties(RocketMQProperties.class)
+@ConditionalOnClass({ MQAdmin.class, ObjectMapper.class })
 @ConditionalOnProperty(prefix = "spring.rocketmq", value = "name-server")
 @Import(ListenerContainerConfiguration.class)
+@AutoConfigureAfter(JacksonAutoConfiguration.class)
 public class RocketMQAutoConfiguration {
 
+    @Bean
+    @ConditionalOnMissingBean(ObjectMapper.class)
 
 Review comment:
   @walking98 I am also confused why we must create a new ObjectMapper here. I also found too many dedicated named instance in older code. I think we should re-think the reusable components in spring components. We really allow many groupId and many topic existing in one instance, to mapping spring concept, how many instance should we allow? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services