Reputation: 32994
Spring Cloud Stream's file-supplier dependency includes FileSupplierConfiguration
which configures a File message source (from Spring Integration). I need to customize the FileReadingMessageSource
that this @Configuration provides, but I'm not sure of the best way to do so. It provided only basic properties to control its @Bean
s, but I need more.
I considered excluding FileSupplierConfiguration
from the app, but I'd then have to copy most of the code from it into my own @Confguration class. Obviously that's a less than ideal solution.
So how can I customize the File message source, for example with additional FileListFilter
s?
Upvotes: 1
Views: 130
Reputation: 1723
Add a BeanPostProcessor
@Bean, like this:
@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;
}
};
}
Upvotes: 1