Translated Spring Integration beans from xml to Java. Now I get new console log for every @InboundChannelAdapter which I didn't get before:
AbstractPollingEndpoint task-scheduler-7 DEBUG Received no Message during the poll, returning 'false'
here's the initial config:
<file:inbound-channel-adapter id="the-file-input"
directory="file:${import.file.dir.incomingFileDir}" channel="the-input" filter="customFilter" />
<si:channel id="the-input" />
<si:service-activator input-channel="the-input"
output-channel="job-requests" ref="theJobLauncher" />
<bean id="theJobLauncher" class="com.example.POJO">
</bean>
New Java Config:
@Bean(name="theInput")
public MessageChannel manifestInputChannel() {
return new DirectChannel();
}
@Bean(name="theFileInput")
@InboundChannelAdapter(channel="theInput")
public MessageSource<File> filesInboundChannelAdapter(@Value("${import.file.dir.incomingFileDir}") String incomingDirectory){
FileReadingMessageSource sourceReader = new FileReadingMessageSource();
sourceReader.setDirectory(new File(incomingDirectory));
sourceReader.setFilter(customFileFilter);
sourceReader.afterPropertiesSet();
return sourceReader;
}
@Bean
@ServiceActivator(inputChannel="theInput", outputChannel="jobRequestsChannel")
public Pojo theJobLauncher() {
Pojo theJobLauncher = new Pojo();
return theJobLauncher;
}
theJobJaucher reference a class with a @MessageEndpoint annotation and @ServiceActivator method
Is this new console log line normal or there is a problem with my configuration?
What you are referring is exactly in the AbstractPollingEndpoint
:
if (message == null) {
if (this.logger.isDebugEnabled()) {
this.logger.debug("Received no Message during the poll, returning 'false'");
}
result = false;
}
So, that mean definitely that you have somehow configured your logger for the org.springframework.integration
category to DEBUG
level.
This doesn't hurt though at all. You just don't have that logging configuration in your previous version.
You don't need to call sourceReader.afterPropertiesSet();
yourself. That is an application context callback and it is indeed going to be called because you declare it as a bean.
Your @ServiceActivator
definition is not correct. The @Bean
annotation can be there only if you use a MessageHandler
implementation.
You can move @ServiceActivator(inputChannel="theInput", outputChannel="jobRequestsChannel")
to the Pojo
method and just use a @Bean
to declare a bean for that Pojo
. Or since you use already @MessageEndpoint
on that class, you can consider turn on @ComponentScan
to let application context to pick up your class a a bean.
Another way is really like MessageHandler
implementation with the call for your Pojo
:
@Bean
@ServiceActivator(inputChannel="theInput", outputChannel="jobRequestsChannel")
public MessageHandler theJobLauncherServiceActivator(Pojo theJobLauncher) {
return new MethodInvokingMessageHandler(theJobLauncher, (String) null);
}