如何在Spring Cloud Stream中添加或调整文件供应商的配置 [英] How to add or adjust the configuration of the file supplier in Spring Cloud Stream
本文介绍了如何在Spring Cloud Stream中添加或调整文件供应商的配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Spring Cloud Stream的文件-供应商依赖包括FileSupplierConfiguration
,它配置一个文件消息源(来自Spring集成)。我需要定制这个@配置提供的FileReadingMessageSource
,但我不确定最好的方法。它仅提供了控制其@Bean
%s的基本属性,但我需要更多。
我考虑将FileSupplierConfiguration
从应用程序中排除,但之后我必须将其中的大部分代码复制到我自己的@Confgation类中。显然,这不是一个理想的解决方案。
那么如何自定义文件消息源,例如使用其他FileListFilter
?
推荐答案
添加一个BeanPostProcessor
@Bean,如下:
@Bean
public BeanPostProcessor inboundFileAdaptorCustomizer() {
return new BeanPostProcessor() {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof FileInboundChannelAdapterSpec) {
//add filter function here
((FileInboundChannelAdapterSpec) bean).filter(files -> ...);
}
return bean;
}
};
}
这篇关于如何在Spring Cloud Stream中添加或调整文件供应商的配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文