【问题标题】:Generate Spring-integration daily statistics report生成 Spring-Integration 每日统计报表
【发布时间】:2019-04-19 16:00:31
【问题描述】:

有一个 spring 集成应用程序,其中使用 s3-outbound-channel-adapter 将文件从文件夹路由到 S3 存储桶。如果文件处理成功,则文件将被移动到相应的目标桶中。如果有错误,文件通过错误通道移动到错误桶。

必须在包含以下详细信息的文本文件中生成每日统计报告。

处理的文件总数: 完全成功: 总错误:

想知道如何获得成功/错误处理的文件数。有什么办法可以达到这个要求。

任何建议或示例都会有所帮助。

通过文档中的 DefaultMessageChannelMetrics 和 Micrometer 集成。不确定它是否能满足我的要求。

有单独的网关和适配器来处理成功和错误文件。

成功:

<int-aws:s3-outbound-gateway id="s3FileMover"
        request-channel="filesOutS3GateWay"
        reply-channel="filesOutS3ChainChannel"
        transfer-manager="transferManager"
        bucket-expression = "headers.TARGET_PATH"
        key-expression="headers.file_name"
        command="UPLOAD">
        <int-aws:request-handler-advice-chain>
            <ref bean="retryAdvice" />
        </int-aws:request-handler-advice-chain>
    </int-aws:s3-outbound-gateway>

错误:

<int-aws:s3-outbound-channel-adapter id="filesErrorS3Mover"
            channel="filesErrorS3MoverChannel"
            transfer-manager="transferManager"
            bucket="${aws.s3.error.bucket}"
             key-expression="headers.TARGET + '/' + headers.file_name"
            upload-metadata-provider = "fileMetaDataProvider"
            command="UPLOAD">
            <int-aws:request-handler-advice-chain>
                <bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
                    <property name="onSuccessExpressionString" value="payload.delete()"/>
                </bean>
            </int-aws:request-handler-advice-chain>

【问题讨论】:

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


    【解决方案1】:

    您可以直接在消息通道上直接查询和重置MessageChannelMetrics

    getSendCount();
    reset();
    

    所有标准消息通道都实现了该接口,因此只需注入通道...

    @Autowired
    private MessageChannelMetrics filesOutS3GateWay;
    
    private int getCount() {
        return this.filesOutS3GateWay.getSendCount();
    }
    

    【讨论】:

    • 谢谢。您能否分享一些示例链接如何实现它.. 观察到 MessageChannelMetrics 是一个接口。想知道如何实现 getSendCount 方法...不确定我是否理解正确。
    • 所有标准频道都实现它;我编辑了答案。
    猜你喜欢
    • 1970-01-01
    • 2018-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多