簡體   English   中英

為什么 Apache Camel Main 會忽略 YAML DSL AWS2-S3 到 AWS2-S3 路由中的目標存儲桶名稱?

[英]Why is Apache Camel Main ignoring the destination bucket name in a YAML DSL AWS2-S3 to AWS2-S3 route?

我正在使用 Apache Camel Main(參見https://camel.apache.org/components/next/others/main.html )組件版本 3.19 並且在我的 route.88392981823204 中指定了以下 AWS2-S3 到 AWS3-S3 路由文件:

- route:
    from:
      uri: "aws2-s3:arn:aws:s3:source-bucket"
      parameters:
        region: "eu-central-1"
        accessKey: "xxxxx"
        secretKey: "xxxxx"
        deleteAfterRead: "false"
      steps:
        - to:
            uri: "aws2-s3:arn:aws:s3:destination-bucket"
            parameters:
              region: "eu-central-1"
              accessKey: "xxxxx"
              secretKey: "xxxxx"

我的應用程序如下所示:

public class MyApp {
    public static void main(String[] args) throws Exception {
        Main main = new Main(MyApp .class);
        main.run(args);
    }

}

上述路由和應用程序的目的是將所有文件從source-bucket復制到destination-bucket

當我運行該應用程序時,兩個存儲桶都已經存在,而source-bucket包含一些文件,而destination-bucket是空的。

但是,似乎所有文件都已復制回source-bucket ,同時覆蓋現有文件,而不是將文件復制到destination-bucket中。 此外,在運行該應用程序后, destination-bucket仍然是空的。

這是 Camel Main 中的錯誤還是我的route.yaml

在此先感謝您的幫助。

這是因為來自原始存儲桶源存儲桶的消費者提供了一個包含其名稱的 header。 這個 header 將覆蓋生產者中的目標到目標桶。

您的代碼應如下所示:

- route:
    from:
      uri: "aws2-s3:arn:aws:s3:source-bucket"
      parameters:
        region: "eu-central-1"
        accessKey: "xxxxx"
        secretKey: "xxxxx"
        deleteAfterRead: "false"
      steps:
        - remove-header:
          name: "CamelAwsS3BucketName"
        - to:
            uri: "aws2-s3:arn:aws:s3:destination-bucket"
            parameters:
              region: "eu-central-1"
              accessKey: "xxxxx"
              secretKey: "xxxxx"

這樣您就不會將 header 帶到下一個端點。

這發生在這里: https://github.com/apache/camel/blob/main/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3 /utils/AWS2S3Utils.java#L46

您還可以查看生產者端的 copyObject 操作: https://github.com/apache/camel/blob/main/components/camel-aws/camel-aws2-s3/src/main/java/org/apache /駱駝/組件/aws2/s3/AWS2S3Producer.java#L403

順便說一句,刪除 header 后一切都應該按預期工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM