【发布时间】:2015-12-01 12:01:18
【问题描述】:
我想从 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 表达式。
我是新手,请帮忙
【问题讨论】: