我想从ftp读取文件,并将其存储在本地根目录下与远程文件相同的路径中(我需要它来处理文件)。远程文件路径是动态的,并且会根据筛选器进行更改。(当service-activator
调用方法pull时处理该文件)
<int:channel id="ftpChannel">
<int:queue/>
</int:channel>
<int-ftp:inbound-channel-adapter id="ftpInbound"
channel="ftpChannel" session-factory="ftpSessionFactory"
auto-create-local-directory="true" delete-remote-files="true"
remote-directory="/"
remote-file-separator="/" temporary-file-suffix=".writing"
local-filename-generator-expression ="/+=#this"
local-directory="${mfg.root.dir}">
<int:poller fixed-rate="50000" />
</int-ftp:inbound-channel-adapter>
<bean id= "directoryFilter" class="il.co.mit.mfg.filter.FilterClass" scope="prototype" >
<property name="channelType" value="****"/>
<property name="rootFolder" value="${mfg.root.dir}"/>
</bean>
<int:channel id="pubSubChannel">
<int:queue/>
</int:channel>
<int:channel id="output">
<int:queue/>
</int:channel>
<file:inbound-channel-adapter id="inboundfolder"
channel="pubSubChannel"
directory="${mfg.root.dir}"
prevent-duplicates="false">
</file:inbound-channel-adapter>
<int:poller default="true" fixed-delay="5000">
<int:transactional transaction-manager="transactionManager" />
</int:poller>
<int:service-activator id="inputFileServiceActivator"
input-channel="pubSubChannel" method="pull" ref="typeAdapter" output-channel="output">
</int:service-activator>
<bean id="ftpSessionFactory"
class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
<property name="host" value="*****" />
<property name="port" value="21" />
<property name="username" value="******" />
<property name="password" value="******" />
<property name="clientMode" value="0" />
<property name="fileType" value="2" />
<property name="bufferSize" value="100000" />
</bean>
我一直在尝试使用local-filename-generator-expression
,但我不确定如何编写SpEL表达式。我对此有点陌生,请帮助
不清楚是什么意思
远程文件路径是动态的,并且会根据筛选器进行更改。
远程路径是一个文字;过滤器无法改变它。
remote-directory="/"
如果您只是想使用远程文件名作为本地文件名(这将是默认值),只需省略local-filename-generator-expression
即可。
如果你真的想要动态路径而不是文件名,那么最好使用ftp出站网关;在那里,您可以完全控制远程和本地路径。