我目前使用来自 spring 集成 aws 的 S3StreamingMessageSource。我将流传递给集成流。
public MessageSource<InputStream> s3InboundStreamingMessageSource() {
S3StreamingMessageSource messageSource = new S3StreamingMessageSource(template());
messageSource.setRemoteDirectory(bucketName);
messageSource.setFilter(new S3PersistentAcceptOnceFileListFilter(new SimpleMetadataStore(),
"streaming"));
return messageSource;
}
@Bean
public IntegrationFlow s3IntegrationFlow() {
return IntegrationFlows.from(s3InboundStreamingMessageSource(), spec -> spec.poller(Pollers.fixedDelay(10, TimeUnit.SECONDS)))
.transform(new S3ObjectInputStreamToStringTransformer())
.transform(Transformers.toJson())
.handle(Http.outboundGateway("http://localhost:8099/create").httpMethod(HttpMethod.POST).extractPayload(true))
.channel("nullChannel")
.get();
}
如何从 S3 中删除检索到的远程文件?
在 S3InboundFileSynchronizer 中有一个方法。
像这样:
@Bean
public S3InboundFileSynchronizer s3InboundFileSynchronizer() {
S3InboundFileSynchronizer synchronizer = new S3InboundFileSynchronizer(factory);
synchronizer.setDeleteRemoteFiles(true);
synchronizer.setPreserveTimestamp(true);
synchronizer.setRemoteDirectory(bucketName);
return synchronizer;
}
谁能帮助我或告诉我一个好的解决方法?