我们正在将弹簧与S3集成在一起。我们有s3-inbound-streaming-channel-adapter从S3读取。发生的情况是,如果“ get”失败,则s3-inbound-streaming-channel-adapter会将文件名放入“ acceptOnceFilter”中,并且不会重试失败。
Q1。我们想要的是当s3-inbound-streaming-channel-adapter从S3中“获取”文件并说由于某种原因而导致此“获取”失败时...我们如何将s3-inbound-streaming-channel-adapter获取到对相同文件再次重试此“获取”请求?
Q2。失败时,会将异常从s3-inbound-streaming-channel-adapter发送到默认的“ errorChannel”。异常中的消息是否包含失败的“文件名”?
<int:channel id="s3FileProcessingChannel">
<int:queue capacity="15"/>
</int:channel>
<bean id="metadataStore" class="org.springframework.integration.metadata.SimpleMetadataStore"/>
<bean id="acceptOnceFilter"
class="org.springframework.integration.aws.support.filters.S3PersistentAcceptOnceFileListFilter">
<constructor-arg index="0" ref="metadataStore"/>
<constructor-arg index="1" value="streaming"/>
</bean>
<int-aws:s3-inbound-streaming-channel-adapter id="s3Region1"
channel="s3FileProcessingChannel"
session-factory="s3SessionFactory"
filter="acceptOnceFilter"
remotedirectoryexpression="'${s3.sourceBucket}/emm'">
<int:poller fixed-delay="1000" max-messages-per-poll="15"/>
</int-aws:s3-inbound-streaming-channel-adapter>
谢谢 总经理
答案 0 :(得分:1)
S3PersistentAcceptOnceFileListFilter
实现:
/**
* A {@link FileListFilter} that can be reset by removing a specific file from its
* state.
* @author Gary Russell
* @since 4.1.7
*
*/
public interface ResettableFileListFilter<F> extends FileListFilter<F> {
/**
* Remove the specified file from the filter so it will pass on the next attempt.
* @param f the element to remove.
* @return true if the file was removed as a result of this call.
*/
boolean remove(F f);
}
然后S3StreamingMessageSource
填充以下标题:
return getMessageBuilderFactory()
.withPayload(session.readRaw(remotePath))
.setHeader(IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE, session)
.setHeader(FileHeaders.REMOTE_DIRECTORY, file.getRemoteDirectory())
.setHeader(FileHeaders.REMOTE_FILE, file.getFilename())
.setHeader(FileHeaders.REMOTE_FILE_INFO,
this.fileInfoJson ? file.toJson() : file);
发生错误时,您只需要使用该FileHeaders.REMOTE_FILE
来调用上面的remove()
,您的失败文件将在下一个轮询周期从S3中提取。