issue#2040

转移RocketMQConfigBeanPostProcessor和CompositeMessageConverter从RocketMQBinderAutoConfiguration至ExtendedBindingHandlerMappingsProviderConfiguration

从RocketMQBinderAutoConfiguration中注入会被stream代理生成一个新的上下文层,上层使用者和它会被隔离导致无法使用
原来是通过spirng.binders经过spring-cloud-stream代理
pull/2041/head
Spike 4 years ago
parent ba80fcac2f
commit 10e9a99d08

@ -19,10 +19,14 @@ package com.alibaba.cloud.stream.binder.rocketmq.autoconfigurate;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.cloud.stream.binder.rocketmq.convert.RocketMQMessageConverter;
import com.alibaba.cloud.stream.binder.rocketmq.custom.RocketMQConfigBeanPostProcessor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.source.ConfigurationPropertyName;
import org.springframework.cloud.stream.config.BindingHandlerAdvise.MappingsProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.converter.CompositeMessageConverter;
@Configuration
public class ExtendedBindingHandlerMappingsProviderConfiguration {
@ -42,4 +46,16 @@ public class ExtendedBindingHandlerMappingsProviderConfiguration {
};
}
@Bean
public RocketMQConfigBeanPostProcessor rocketMQConfigBeanPostProcessor() {
return new RocketMQConfigBeanPostProcessor();
}
@Bean(RocketMQMessageConverter.DEFAULT_NAME)
@ConditionalOnMissingBean(name = { RocketMQMessageConverter.DEFAULT_NAME })
public CompositeMessageConverter rocketMQMessageConverter() {
return new RocketMQMessageConverter().getMessageConverter();
}
}

@ -18,7 +18,6 @@ package com.alibaba.cloud.stream.binder.rocketmq.autoconfigurate;
import com.alibaba.cloud.stream.binder.rocketmq.RocketMQMessageChannelBinder;
import com.alibaba.cloud.stream.binder.rocketmq.actuator.RocketMQBinderHealthIndicator;
import com.alibaba.cloud.stream.binder.rocketmq.convert.RocketMQMessageConverter;
import com.alibaba.cloud.stream.binder.rocketmq.properties.RocketMQBinderConfigurationProperties;
import com.alibaba.cloud.stream.binder.rocketmq.properties.RocketMQExtendedBindingProperties;
import com.alibaba.cloud.stream.binder.rocketmq.provisioning.RocketMQTopicProvisioner;
@ -26,11 +25,9 @@ import com.alibaba.cloud.stream.binder.rocketmq.provisioning.RocketMQTopicProvis
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.converter.CompositeMessageConverter;
/**
* issue:https://github.com/alibaba/spring-cloud-alibaba/issues/1681 .
@ -49,12 +46,6 @@ public class RocketMQBinderAutoConfiguration {
@Autowired
private RocketMQBinderConfigurationProperties rocketBinderConfigurationProperties;
@Bean(RocketMQMessageConverter.DEFAULT_NAME)
@ConditionalOnMissingBean(name = { RocketMQMessageConverter.DEFAULT_NAME })
public CompositeMessageConverter rocketMQMessageConverter() {
return new RocketMQMessageConverter().getMessageConverter();
}
@Bean
@ConditionalOnEnabledHealthIndicator("rocketmq")
@ConditionalOnClass(name = "org.springframework.boot.actuate.health.HealthIndicator")

@ -1,3 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.alibaba.cloud.stream.binder.rocketmq.autoconfigurate.ExtendedBindingHandlerMappingsProviderConfiguration,\
com.alibaba.cloud.stream.binder.rocketmq.custom.RocketMQConfigBeanPostProcessor
com.alibaba.cloud.stream.binder.rocketmq.autoconfigurate.ExtendedBindingHandlerMappingsProviderConfiguration
Loading…
Cancel
Save