没有为通道适配器定义轮询器
Posted
技术标签:
【中文标题】没有为通道适配器定义轮询器【英文标题】:No poller has been defined for channel Adapter 【发布时间】:2015-11-11 21:19:03 【问题描述】:我使用一个入站通道下载文件,然后使用另一个出站通道上传文件,我不需要任何轮询器,但不知道为什么会出现此异常。有人可以帮我解决这个问题。我正在使用 spring 4.0.6 集成和 spring core 4.0.6。
日志跟踪:
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>
【问题讨论】:
【参考方案1】:好吧,看来您必须回到theory 并了解polling
和event-listening
之间的区别。
另一方面,您应该同意 SFTP 是某种远程文件系统,实际上没有其他方法可以从那里下载新文件,除非 轮询。当我们想从表中读取新记录等时,该规则适用于 JDBC。
所以,既然我们同意<int-sftp:inbound-channel-adapter>
正是Polling Consumer
,我们必须声明<poller>
,隐含地或像global
一样。
这是从现有设计和您的配置方面来看的。
从另一面告诉我们你的意思:
我不需要任何轮询器
您打算如何从 SFTP 下载文件?
是的,实际上<int-sftp:outbound-gateway>
可以为你做这些事情,但那是一个有点不同的故事......
【讨论】:
啊我的坏...我想我应该编辑这个问题。是的,你是对的 Inbound 必须有 poller。 入站通道运行良好,但在出站通道适配器方面出现异常:调度程序没有订阅者。 也对。您的入站适配器使用requestSFTPSEDEVChannel
,我真的没有看到任何订阅者。您的出站适配器使用不同的通道 - requestOutBoundChannel
。那是你的“地狱”。抱歉,我无法帮助您解决注意力不集中的问题...以上是关于没有为通道适配器定义轮询器的主要内容,如果未能解决你的问题,请参考以下文章
Sprint 集成 DSL - Http 入站适配器和轮询器