Spring integration Spring集成未拾取任何文件
以下是我的配置。直到最近,我才能够调查文件。现在过滤器总是得到一个空的文件列表。我所做的唯一更改是安装卡巴斯基防病毒软件。希望这不是问题。我可以通过命令提示符和浏览器成功访问ftp 会议:Spring integration Spring集成未拾取任何文件,spring-integration,Spring Integration,以下是我的配置。直到最近,我才能够调查文件。现在过滤器总是得到一个空的文件列表。我所做的唯一更改是安装卡巴斯基防病毒软件。希望这不是问题。我可以通过命令提示符和浏览器成功访问ftp 会议: <int:channel id="ftpChannel"/> <int-ftp:inbound-channel-adapter id="ftpInbound1" channel="ftpChannel" session-factory="ftpClientFac
<int:channel id="ftpChannel"/>
<int-ftp:inbound-channel-adapter id="ftpInbound1"
channel="ftpChannel"
session-factory="ftpClientFactory"
charset="UTF-8"
local-directory="file:${paths.root}"
delete-remote-files="false"
temporary-file-suffix=".writing"
remote-directory="${file.ftpfolder}"
preserve-timestamp="true"
auto-startup="true"
filter="compositeFilterLocal"
>
<int:poller max-messages-per-poll="10000" fixed-rate="1000" error-channel="errorChannel"/>
</int-ftp:inbound-channel-adapter>
<int-ftp:outbound-channel-adapter id="ftpOutbound"
channel="ftpChannel"
session-factory="ftpClientFactory"
charset="UTF-8"
remote-file-separator="/"
auto-create-directory="true"
remote-directory="DMS"
use-temporary-file-name="true"
temporary-file-suffix=".writing">
</int-ftp:outbound-channel-adapter>
<!-- <bean id="acceptAllFilter" class="org.springframework.integration.file.filters.AcceptAllFileListFilter" /> -->
<bean id="compositeFilterLocal" class="org.springframework.integration.file.filters.CompositeFileListFilter">
<constructor-arg>
<list>
<!-- Ensures that the file is whole before processing it -->
<bean class="org.springframework.integration.file.filters.AcceptAllFileListFilter" />
<bean class="com.polling.util.CustomFileFilterLocal"/>
<!-- Ensures files are picked up only once from the directory -->
</list>
</constructor-arg>
</bean>
请告诉我里面有什么需要改变的…谢谢
如果需要更多信息,请告诉我
编辑::更新
如果我使用apachecommons-net-3.3从同一文件夹检索同一个文件,它工作正常,允许我获取文件并下载。因此,这与jvm访问ftp站点无关
过滤器的代码很简单。目前我只使用它进行模式匹配
@Override
public List<File> filterFiles(File[] files)
{
List<File> ret = new ArrayList<File>();
Pattern pattern = Pattern.compile(".*?~.*?");//(".*?@.*?@.*?");
DocumentFile documentFile;
Matcher matcher;
for (File file : files)
{
matcher = pattern.matcher(file.getName());
if(matcher.find())// matching the input file name pattern
{
//get key and documentfile
//create sha key to check file existance
String key = EncodeUtil.generateKey(file);
documentFile = documentDaoImpl.getDocumentFile(key,Constants.INPROGRESS);
if (documentFile != null)
{
ret.add(file);
}
}/*else
{
file.delete();
}*/
}
return ret;
}
@覆盖
公共列表筛选器文件(文件[]文件)
{
List ret=new ArrayList();
Pattern=Pattern.compile(“.*?~.*?”);/(“*?@.*?@.*?”);
文档文件;
匹配器匹配器;
用于(文件:文件)
{
matcher=pattern.matcher(file.getName());
if(matcher.find())//匹配输入文件名模式
{
//获取密钥和文档文件
//创建sha密钥以检查文件是否存在
String key=EncodeUtil.generateKey(文件);
documentFile=documentDaoImpl.getDocumentFile(key,Constants.INPROGRESS);
if(documentFile!=null)
{
ret.add(文件);
}
}/*否则
{
delete();
}*/
}
返回ret;
}
我已经成功地与此工作了至少几个月,现在突然我没有得到任何文件!!
目前,我正在使用计时器cron表达式,并将在触发类中使用ApacheCommonsNet进行ftp。尽管有spring ftp标签,但要做ftp似乎是一种浪费。我已经用您使用的配置构建了一个项目,而且一切似乎都很好 您的代码中有一些部分(未在此处发布)可能会导致丢弃筛选器中的文件,您必须进行检查(添加日志消息将有帮助):
很抱歉,但这确实是不够的信息。日志中有错误吗?您的
CustomFileFilterLocal
做什么?您是否可以调试FTP的Spring集成类,以确保FtpSession
为LS
命令-AbstractInboundFileSynchronizer
返回什么?日志中没有错误,只传输了消息0个文件。我可以在筛选器中检查它正在轮询的目录吗?
if (matcher.find())// matching the input file name pattern
{
// get key and documentfile
// create sha key to check file existance
// TODO: does this call throw any exception? return null?
String key = EncodeUtil.generateKey(file);
documentFile = documentDaoImpl.getDocumentFile(key, Constants.INPROGRESS);
if (documentFile != null) {
ret.add(file);
}
else {
// TODO: Log here that your DAO implementation did not return anything for this specific file
}
}
else {
// TODO: Log here that the file does not meet the naming convention
}