有人遇到吗?基本上,我的目标是即使应用程序被退回也要处理一次文件
@Bean
public S3InboundFileSynchronizer s3InboundFileSynchronizer() throws Exception {
S3InboundFileSynchronizer synchronizer = new S3InboundFileSynchronizer(amazonS3());
synchronizer.setDeleteRemoteFiles(false);
synchronizer.setPreserveTimestamp(true);
synchronizer.setRemoteDirectory(sourceBucket + "/dir/");
synchronizer.setFilter(new S3PersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "simpleMetadataStore"));
return synchronizer;
}
private AmazonS3 amazonS3() throws Exception {
return clientFactory.getClient(AmazonS3.class);
}
@Bean
@InboundChannelAdapter(value = "s3FilesChannel", poller = @Poller(fixedDelay = "5000"))
public S3InboundFileSynchronizingMessageSource s3InboundFileSynchronizingMessageSource() throws Exception {
S3InboundFileSynchronizingMessageSource messageSource =
new S3InboundFileSynchronizingMessageSource(s3InboundFileSynchronizer());
messageSource.setAutoCreateLocalDirectory(true);
messageSource.setLocalDirectory(new File("c:/temp/"));
messageSource.setLocalFilter(new FileSystemPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "fsSimpleMetadataStore"));
return messageSource;
}
答案 0 :(得分:0)
您的问题是使用内存SimpleMetadataStore
,因此在应用程序重新启动后,您将丢失存储在其中的所有信息。
考虑改用一些持久性存储实现,例如对于AWS,我们有一个DynamoDbMetadataStore
:https://github.com/spring-projects/spring-integration-aws#metadata-store-for-amazon-dynamodb