作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用一个入站 channel 来下载文件,然后使用其他出站 channel 来上传文件,我不需要任何轮询器,但不知道为什么会出现此异常。有人可以帮我解决这个问题吗?我正在使用 spring 4.0.6 Integration 和 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>
最佳答案
好吧,看起来你必须回到 theory并了解 polling
之间的区别和event-listening
.
从另一方面来看,您应该同意 SFTP 是某种远程文件系统,并且确实没有其他方法可以从那里下载新文件,除非轮询。当我们想从表中读取新记录等时,该规则适用于 JDBC。
既然我们同意 <int-sftp:inbound-channel-adapter>
正是Polling Consumer
,我们必须声明<poller>
,隐含地或像 global
一。
这是从现有设计和您的配置方面来看的。
从另一面让我们知道您的意思:
i do not need any poller
您将如何从 SFTP 下载文件?是的,实际上<int-sftp:outbound-gateway>
可以为您做这些事情,但这是一个有点不同的故事......
关于java - 尚未为 channel 适配器定义轮询器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32080850/
我是一名优秀的程序员,十分优秀!