Ralph
Ralph

Reputation: 15

How to define an idempotent consumer in Apache Camel YAML DSL using a combination of headers?

I am using the Camel Main component version 3.19 with the following YAML DSL route to successfully load files from an AWS/S3 bucket to the local file system:

- 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:/..."

However, in addition to the header CamelAwsS3Key I also want to include the header CamelAwsS3LastModified in order to enforce that files renewed on S3 while this route is running are not skipped. Using an equivalent route in Java DSL and appending the key CamelAwsS3LastModified as shown below works fine:

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

How can I define the combined header as part of the idempotent-consumer spec in the same way in the YAML DSL route above?

Upvotes: 1

Views: 585

Answers (1)

Nicolas Filotto
Nicolas Filotto

Reputation: 45005

I'm afraid that what you are trying to do is not possible with the YAML DSL, as workaround, you can replace your expression with the corresponding simple expression, something like:

...
    - idempotent-consumer:
        idempotent-repository: "IdempotentRepositoryBean"
        simple: "${header.CamelAwsS3Key}${header.CamelAwsS3LastModified}"
        skip-duplicate: true
...

Upvotes: 0

Related Questions