Spring integration 使用spring集成从sFtp服务器传输pdf文件(完整的Ftp)
我试着在一个地方执行这个例子 我尝试使用发行版中给出的示例(sFtpInboundReceiveSample.java)将文件从远程目录传输到本地目录 因此,我安装了一个真正的sFtp服务器(完整的FTP),创建了一个帐户,为用户生成了一个私钥/公钥,然后尝试启动tge示例测试类 我的目标是从远程sFtp服务器检索pdf二进制文件并将其存储在本地目录中 不幸的是,在尝试接收第一个.pdf文件时,示例程序仍然处于停滞状态 即:创建了一个临时test1.pdf.writing文件,但该文件从未被完全下载 因此,一段时间后,测试以错误结束。有人能帮我决定做什么吗Spring integration 使用spring集成从sFtp服务器传输pdf文件(完整的Ftp),spring-integration,Spring Integration,我试着在一个地方执行这个例子 我尝试使用发行版中给出的示例(sFtpInboundReceiveSample.java)将文件从远程目录传输到本地目录 因此,我安装了一个真正的sFtp服务器(完整的FTP),创建了一个帐户,为用户生成了一个私钥/公钥,然后尝试启动tge示例测试类 我的目标是从远程sFtp服务器检索pdf二进制文件并将其存储在本地目录中 不幸的是,在尝试接收第一个.pdf文件时,示例程序仍然处于停滞状态 即:创建了一个临时test1.pdf.writing文件,但该文件从未被完全
下面是我在spring.xml文件中使用的配置:
<int-sftp:inbound-channel-adapter id="sftpInbondAdapter" auto-startup="false" channel="receiveChannel" session-factory="sftpSessionFactory" local-directory="file:local-mumuFolder" remote-directory="mumuFolder" auto-create-local-directory="true" delete-remote-files="false" filename-regex=".*\.pdf$"> <int:poller fixed-rate="1000" max-messages-per-poll="1"/> </int-sftp:inbound-channel-adapter>
java中的示例代码到此为止:
公共类SftpInboundReceiveSample{
@Test
public void runDemo(){
ConfigurableApplicationContext context =
new ClassPathXmlApplicationContext("/META-INF/spring/integration/SftpInboundReceiveSample-context.xml", this.getClass());
RemoteFileTemplate<LsEntry> template = null;
/*String file1 = "a.txt";
String file2 = "b.txt";
String file3 = "c.bar";
new File("local-dir", file1).delete();
new File("local-dir", file2).delete();*/
try {
PollableChannel localFileChannel = context.getBean("receiveChannel", PollableChannel.class);
@SuppressWarnings("unchecked")
SessionFactory<LsEntry> sessionFactory = context.getBean(CachingSessionFactory.class);
template = new RemoteFileTemplate<LsEntry>(sessionFactory);
//SftpTestUtils.createTestFiles(template, file1, file2, file3);
SourcePollingChannelAdapter adapter = context.getBean(SourcePollingChannelAdapter.class);
adapter.start();
Message<?> received = localFileChannel.receive();
@测试
public void runDemo(){
ConfigurableApplicationContext上下文=
新的ClassPathXmlApplicationContext(“/META-INF/spring/integration/SftpInboundReceiveSample context.xml”,this.getClass());
RemoteFileTemplate模板=null;
/*字符串file1=“a.txt”;
字符串file2=“b.txt”;
字符串file3=“c.bar”;
新文件(“本地目录”,file1.delete();
新文件(“本地目录”,file2.delete()*/
试一试{
PollableChannel localFileChannel=context.getBean(“receiveChannel”,PollableChannel.class);
@抑制警告(“未选中”)
SessionFactory SessionFactory=context.getBean(CachingSessionFactory.class);
模板=新的RemoteFileTemplate(sessionFactory);
//createTestFiles(模板、文件1、文件2、文件3);
SourcePollingChannelAdapter=context.getBean(SourcePollingChannelAdapter.class);
adapter.start();
Message received=localFileChannel.receive();
(localFileChannel.receive()指令块不确定
谁能帮帮我吗
感谢并致意以下是我在spring.xml文件中使用的配置:可能您在下载之前没有关闭该远程文件?我的意思是,远程服务器上的文件仍然处于锁定状态。不幸的是,该文件已正确关闭,但我获得以下堆栈跟踪:@Artem下载对于*.txt文件或*。windows上的xml文件,但id不适用于*.exe文件或.pdf您确实应该共享
*.exe
和*.pdf