pom.xmlに依頼の導入:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-box</artifactId>
<version>${camel-version}</version>
</dependency>
使い方(例):
ルートの書き方:
...
String fileId=...;
String fileName=...;
...
from("direct:foo")
.setHeader("CamelBox.fileId", constant(fileId))
.setHeader("CamelBox.output", constant(output))
.to("box://files/download")
.to("file://...");
注意点:
ダウンロードのBoxファイルのリンクと目的のローカルのリンクは".to()"の中に書く。
ルートの使用:
.to("direct:foo")で呼び出すことが可能ですが、
別のルートを使わない場合:
try{
template.sendBody("direct:foo", "This is a test message,please download the file");
}catch(CamelExecutionException e){
System.out.println(e);
}
"direct"はcamelの二つコンポネートの間に連携用のコンポネートです。
"direct:foo"について、"foo"をほかの自分で定義する名でも可能です。
Camel Box:
https://camel.apache.org/components/latest/box-component.html
Camel direct:
https://camel.apache.org/components/latest/direct-component.html