Hi guys,
This issue stumped us for a little while so I thought I'd share and try figure out if it's the expected behaviour, or if an improvement can be made in the SI code (even if it's of the "fail-fast" type).
We have the following element in our applicationContext.
Nothing particularly fancy. The applicationContext.xml used to be loaded by a ContextLoaderListener in web.xml, no servlets. Then at some point I added a SOAP interface to this app, so I created MessageDispatcherServlet in web.xml, and out of laziness assigned its contextConfigLocation to the same applicationContext.xml file as above.Code:<sftp:inbound-channel-adapter id="sftpInboundAdapter" session-factory="sftpSessionFactory" cache-sessions="true" remote-directory="${sftp.remote.dir}" remote-file-separator="/" filename-regex=".*\.txt" delete-remote-files="true" local-directory="#{incomingTempDir.absolutePath}" auto-create-local-directory="true" channel="sftpIncomingFiles"> <integration:poller fixed-delay="${sftp.poller.rate}" error-channel="sftpErrorChannel"/> </sftp:inbound-channel-adapter>
This results in the <sftp:inbound-channel-adapter/> element being loaded twice, but it didn't cause any warnings or errors. What it also does is create two pollers on the same SFTP inbound channel adapter - silently. Which in turn results in files being downloaded and delivered to sftpIncomingFiles twice. I tried adding an "id" attribute to the <poller/> element just to see what that does but it still results in duplicates. I would have expected the bean context to either fail on startup due to the duplicate sftpInboundAdapter definition, or to only create one instance. Instead, it created a second poller which caused unexpected behaviour.
Now the correct thing is to ensure that the channel adapter definition is only loaded once, which I've done. But I'm left wondering if something could not be improved to make this less likely to happen to other people?


Reply With Quote
That poller really doesn't belong in the root application context in the first place.
