如何使用标头组合在 Apache Camel YAML DSL 中定义幂等消费者?

问题描述 投票:0回答:1

我使用带有以下 YAML DSL 路由的 Camel 主要组件版本 3.19 成功地将文件从 AWS/S3 存储桶加载到本地文件系统:

- beans:
    - name: IdempotentRepositoryBean
      type: org.apache.camel.support.processor.idempotent.MemoryIdempotentRepository

- route:
    from:
      uri: "aws2-s3:arn:aws:s3:someBucket"
      parameters:
        # The AWS region hosting the bucket and the access credentials
        # are obtained from Properties file.
        amazonS3Client: "#awss3SourceClient"
        deleteAfterRead: "false"
      steps:
        - idempotent-consumer:
            idempotent-repository: "IdempotentRepositoryBean"
            header: "CamelAwsS3Key"
            skip-duplicate: true
        - set-header:
            name: "CamelFileName"
            simple: "${header.CamelAwsS3Key}"
        - to:
            uri: "file:C:/..."

但是,除了标题

CamelAwsS3Key
之外,我还想包含标题
CamelAwsS3LastModified
以强制执行此路由运行时在 S3 上更新的文件不会被跳过。 在 Java DSL 中使用等效路由并附加密钥
CamelAwsS3LastModified
如下所示可以正常工作:

   route = from(fromEndpoint).
             idempotentConsumer(header("CamelAwsS3Key").
                  append(header("CamelAwsS3LastModified")), idempotentRepository);

如何在上面的 YAML DSL 路由中以相同的方式将组合的

header
定义为
idempotent-consumer
规范的一部分?

yaml apache-camel dsl
1个回答
0
投票

未测试,但您可以尝试用相应的简单表达式替换标题表达式,例如:

...
    - idempotent-consumer:
        idempotent-repository: "IdempotentRepositoryBean"
        simple: "${header.CamelAwsS3Key}${header.CamelAwsS3LastModified}"
        skip-duplicate: true
...
© www.soinside.com 2019 - 2024. All rights reserved.