gpt4 book ai didi

spring-integration - Spring集成ftp-outbound-gateway没有远程文件

转载 作者:行者123 更新时间:2023-12-01 02:25:03 26 4
gpt4 key购买 nike

我一直在做spring集成<int-ftp:outbound-gateway> ,我可以使用 ftp-outbound-gateway 从远程服务器下载文件, 但是有一个我还没有解决的问题,如果远程目录包含文件,系统可以正常工作并且将完成而没有任何问题,但是如果没有文件系统挂断而不从那时起执行。我想继续系统。远程文件夹是否包含文件,

这是我的 ftp 下载配置

 <?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:int="http://www.springframework.org/schema/integration"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp"
xsi:schemaLocation="http://www.springframework.org/schema/integration/ftp
http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">

<context:property-placeholder location="classpath:host.properties"/>

<int:gateway id="gw" service-interface="com.util.ToFtpFlowGateway"
default-request-channel="inbound"/>

<bean id="downloadProcessBean" class="com.util.FTPDownloadInterceptor">
<property name="fileType" value="txt"/>
<property name="sourceType" value="ftp"/>
<property name="destinationName" value="destinationName"/>
<property name="destinationQueName" value="destinationQueName"/>
<property name="sourceAddressDetails" value="sourceAddressDetails"/>
<property name="sourceName" value="sourceName"/>
</bean>

<bean id="ftpSessionFactory"
class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
<property name="host" value="${local.host}"/>
<property name="port" value="${local.availableServerPort}"/>
<property name="username" value="${local.userid}"/>
<property name="password" value="${local.user.password}"/>
</bean>

<int-ftp:outbound-gateway id="gatewayLS" cache-sessions="false"
session-factory="ftpSessionFactory"
request-channel="inbound"
command="ls"
command-options=""
expression="payload"
reply-channel="toSplitter" reply-timeout="10" />

<int:channel id="toSplitter">
<int:interceptors>
<int:wire-tap channel="logger"/>
</int:interceptors>
</int:channel>

<int:logging-channel-adapter id="logger" log-full-message="true" />

<int:splitter id="splitter" input-channel="toSplitter" output-channel="toGet"/>

<int-ftp:outbound-gateway id="gatewayGET" cache-sessions="false"
local-directory="/home/udeshika/project/req/local/download"
session-factory="ftpSessionFactory"
request-channel="toGet"
reply-channel="toRemoveChannel"
command="get"
command-options="-P"
expression="payload.remoteDirectory + '/' + payload.filename" reply-timeout="10"/>

<int-ftp:outbound-gateway id="gatewayRM"
session-factory="ftpSessionFactory" cache-sessions="false"
expression="payload.remoteDirectory + '/'+ payload.filename"
request-channel="toRemoveChannel"
command="rm"
reply-channel="aggregateResultsChannel"
auto-create-local-directory="true"
reply-timeout="10"

/>
<!--<bean id="fileDownloadIntecepter" class="shipxpress.util.FTPDownloadInterceptor"/>-->
<int:channel id="toRemoveChannel">
<int:interceptors>
<int:wire-tap channel="logger2"/>
<!--<int:ref bean="fileDownloadIntecepter" />-->
</int:interceptors>
</int:channel>

<bean class="org.springframework.integration.file.FileReadingMessageSource"
p:directory="${download.directory}"/>

<int:logging-channel-adapter id="logger2" log-full-message="true" />

<int-ftp:outbound-gateway id="gatewayRM"
session-factory="ftpSessionFactory" cache-sessions="false"
expression="headers['file_remoteDirectory'] + '/' + headers['file_remoteFile']"
request-channel="toRemoveChannel"
command="rm"
reply-channel="aggregateResultsChannel"/>

<int:aggregator input-channel="aggregateResultsChannel"/>

</beans>

谁能帮我清除这个,

先感谢您
秀色,

最佳答案

这个流程的问题是 LS 返回一个空列表;当这击中分离器时,它会导致没有消息并且流停止。调用网关的线程永远(默认)等待回复。

向网关添加回复超时,如果没有收到响应,它将返回 null。

<int:gateway id="gw" service-interface="org.springframework.integration.samples.ftp.ToFtpFlowGateway"
default-request-channel="inbound" default-reply-timeout="100" />

只要您使用 Direct channel ,当有实际工作要做时,网关就没有超时的危险,因为直到线程返回网关以查找下游流产生的任何回复时,计时器才会启动。

关于spring-integration - Spring集成ftp-outbound-gateway没有远程文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17207781/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com