我使用Camel Main组件版本3.19,通过以下YAML DSL路由成功地将文件从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
规范的一部分?
1条答案
按热度按时间pgccezyw1#
未测试,但您可以尝试将标头表达式替换为相应的simple expression,如下所示: