【问题标题】:Delete source file from s3 bucket : s3-inbound-streaming-channel-adapter从 s3 存储桶中删除源文件:s3-inbound-streaming-channel-adapter
【发布时间】:2018-11-07 06:44:00
【问题描述】:

源文件在成功传输到目标目录后不会从 s3 存储桶中删除一次。 步骤 1. 使用入站流通道适配器将源文件从 S3 流式传输到本地目录。(工作正常) 第 2 步:想要在成功传输后删除源文件(不工作) 配置代码如下

                        <int-aws:s3-inbound-streaming-channel-adapter id="s3FilesInbound"
                                        channel="s3FilesChannel" 
                                        session-factory="s3SessionFactory" 
                                        filename-regex="^.*\\.(txt|csv)$" 
                                        remote-directory-expression="bucket_name" 
                                        auto-startup="true" >

                                <integration:poller id="s3FilesChannelPoller"
                                                    fixed-delay="1000"
                                                    max-messages-per-poll="1">
                                </integration:poller>
                            </int-aws:s3-inbound-streaming-channel-adapter>


                    <integration:stream-transformer id="streamTransformer" input-channel="s3FilesChannel" output-channel="s3FilesChannelOut"/>

        <integration:chain id="filesS3ChannelChain"
                input-channel="s3FilesChannelOut">
                <file:outbound-gateway
                    id="fileInS3ArchiveChannel"
                    directory="local_directory"
                    filename-generator-expression="headers.file_remoteFile">
                    <file:request-handler-advice-chain>
                        <ref bean="retryAdvice" />
                    </file:request-handler-advice-chain>
                </file:outbound-gateway>
                <integration:gateway request-channel="nullChannel"
                        error-channel="errorChannel" />
            </integration:chain>

问候,

【问题讨论】:

    标签: spring spring-boot spring-integration spring-integration-aws


    【解决方案1】:

    既然你在那里使用&lt;integration:stream-transformer&gt;,我认为没有理由依赖&lt;int-aws:s3-inbound-streaming-channel-adapter&gt;。使用第一个,您只需消除最后一个的流式传输目的。

    我建议你看看常规的&lt;int-aws:s3-inbound-channel-adapter&gt;,它已经有一个delete-remote-files="true" 选项。

    另一方面,你仍然可以用你目前拥有的东西来做到这一点,但你需要像 &lt;integration:outbound-channel-adapter expression="@s3SessionFactory.getSession().remove(headers[file_remoteDirectory] + '/' + headers[file_remoteFile])"&gt; 这样的东西。

    这些标头由AbstractRemoteFileStreamingMessageSource 填充。

    【讨论】:

      猜你喜欢
      • 2018-11-12
      • 1970-01-01
      • 2018-05-16
      • 1970-01-01
      • 2012-05-16
      • 1970-01-01
      • 1970-01-01
      • 2012-04-20
      • 2015-06-23
      相关资源
      最近更新 更多