我使用一个入站频道下载文件&然后其他出站频道上传文件&我不需要任何poller但不知道为什么我得到这个例外。有人可以在这个问题上帮助我。我使用的是spring 4.0.6 Integration和spring core 4.0.6。
Logtrace:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sftpInboundAdapter': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No poller has been defined for channel-adapter 'sftpInboundAdapter', and no default poller is available within the context.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:684)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.canaldigital.tsi.bank.config.AppMain.main(AppMain.java:35)
Caused by: java.lang.IllegalArgumentException: No poller has been defined for channel-adapter 'sftpInboundAdapter', and no default poller is available within the context.
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean.initializeAdapter(SourcePollingChannelAdapterFactoryBean.java:157)
at org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean.afterPropertiesSet(SourcePollingChannelAdapterFactoryBean.java:115)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
ApplicationConfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-sftp="http://www.springframework.org/schema/integration/sftp"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.0.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/sftp
http://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd">
<bean id="sftpSessionFactory" class="org.springframework.integration.file.remote.session.CachingSessionFactory">
<constructor-arg ref="defaultSftpSessionFactory" />
</bean>
<int-sftp:inbound-channel-adapter id="sftpInboundAdapter"
session-factory="sftpSessionFactory"
channel="requestSFTPSEDEVChannel"
filename-pattern="*.*"
remote-directory="/home/oracle/IBSTOBANK/Test/Incoming/"
preserve-timestamp="true"
local-directory="C:/Working_Directory/temp/SE-DEV/"
auto-create-local-directory="true"
temporary-file-suffix=".writing"
delete-remote-files="true">
<!-- <int:poller fixed-rate="1000"/> -->
</int-sftp:inbound-channel-adapter>
<int-sftp:outbound-channel-adapter id="sftpOutboundAdapter"
session-factory="sftpSessionFactory"
channel="requestOutBoundChannel"
remote-directory="/home/oracle/IBSTOBANK/Test/Outgoing/">
</int-sftp:outbound-channel-adapter>
<int:channel id="requestSFTPSEDEVChannel">
</int:channel>
<int:channel id="requestOutBoundChannel">
</int:channel>
答案 0 :(得分:1)
好吧,看起来您必须回到theory并了解polling
和event-listening
之间的区别。
从另一方面来说,您应该同意SFTP是某种远程文件系统,除非轮询,否则没有任何其他方法可以从那里下载新文件。当我们想要从表中读取新记录等时,该规则适用于JDBC。
因此,既然我们同意<int-sftp:inbound-channel-adapter>
完全是Polling Consumer
,我们必须隐式地声明<poller>
,或者像global
那样声明<int-sftp:outbound-gateway>
。
这是现有设计方面的问题以及您对此问题的配置。
从另一方面告诉我们您的意思:
我不需要任何轮询
您打算如何从SFTP下载文件?
是的,实际上@import
可以为你做这些事情,但那是一个不同的故事...