【问题标题】:Inbound channel not working in Spring入站通道在 Spring 中不起作用
【发布时间】:2013-01-15 17:15:39
【问题描述】:

我正在尝试从 FTP 复制文件并希望将其放在本地计算机中。

为此我创建了一个入站通道配置是:

<bean name="publishStockSessionFactory"
      class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
  <property name="host"
        value="10.255.255.1" />
<property name="port" value="21" />
    <property name="username"
        value="test" />
    <property name="password"
        value="test" />
</bean>

<bean id="stockLocalDirectory" class="java.lang.String">
    <constructor-arg
        value="/opt/test" />
</bean>

<bean id="stockRemoteDirectory" class="java.lang.String">
    <constructor-arg
        value="stock" />
</bean>

<int-ftp:inbound-channel-adapter 
     local-directory="# {stockLocalDirectory}"             
     channel="stockFilesFromFTP"  
     session-factory="publishStockSessionFactory" 
     remote-directory="#{stockRemoteDirectory}" 
     delete-remote-files="true" 
     filename-regex="Stock*.csv" >
    <int:poller fixed-rate="120000" max-messages-per-poll="100" />
</int-ftp:inbound-channel-adapter>

<int:publish-subscribe-channel id="stockFilesFromFTP" />

启动时出现的错误是

INFO   | jvm 1    | main    | 2013/01/15 22:20:02.715 | 2013-01-15 22:20:02,699 
ERROR  task-scheduler-4     ErrorHandler            : failed to send message 
to  channel 'stockFilesFromFTP' within timeout: -1

我们打开的调试是

log4j.logger.org.springframework.aop=DEBUG
org.springframework.integration.channel.DirectChannel=DEBUG
org.springframework.integration.channel.MessagePublishingErrorHandler=DEBUG
org.springframework.integration.config.xml.PointToPointChannelParser=DEBUG

你能建议我如何调试这个错误吗?

【问题讨论】:

    标签: spring spring-aop spring-integration


    【解决方案1】:

    使用调试级别日志记录运行。

    您必须在频道stockFilesFromFTP 上拥有至少一位订阅者。

    【讨论】:

    • 感谢 Russell,以上调试已开启,但日志中没有信息。我们在上面的配置中添加了频道的订阅者。是对的吗?
    • Rusell。我打开了 org.springframework.integration ,日志中没有与集成相关的信息。如果入站如何找出根本原因。
    【解决方案2】:

    我对 FTPclientfactory bean 使用了以下类型的配置。它也有超时参数,所以如果您因连接超时而遇到问题,这将对您有所帮助。

    <bean id="testapp.standardFTPClientFactory" class="org.springframework.integration.ftp.DefaultFTPClientFactory"
            abstract="true">
            <property name="host" value="${ftp.host}"/>
            <property name="username" value="${ftp.username}"/>
            <property name="password" value="${ftp.password}"/>
            <property name="port" value="${ftp.port}"/>
            <property name="remoteWorkingDirectory" value="${ftp.remotedir}"/>
            <property name="dataTimeout" value="3600000"/>
            <property name="connectTimeout" value="${ftp.connectTimeout}"/>
            <property name="clientMode" value="2"/>
    </bean>
    

    【讨论】:

      猜你喜欢
      • 2017-05-08
      • 1970-01-01
      • 1970-01-01
      • 2018-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多