【发布时间】:2020-12-29 07:17:37
【问题描述】:
我编写了一个骆驼路由,它轮询文件夹并将其发送到 Azure Blob 容器
我按照 Azure 文档页面中提到的示例进行操作 https://github.com/apache/camel/blob/master/components/camel-azure/src/main/docs/azure-blob-component.adoc
我正在反转路线。我使用的是 Azure Blob 生产者,而不是消费者。 这是我的路线。我使用过 Java DSL。
from("file://C:/camel/source1").to("azure-blob://datastorage/container1/BLOB1?credentials=#credentials&operation=updateBlockBlob")
当我放置文件时,出现以下错误。
**java.lang.IllegalArgumentException: Unsupported blob type:org.apache.camel.component.file.GenericFile
at org.apache.camel.component.azure.blob.BlobServiceProducer.getInputStreamFromExchange(BlobServiceProducer.java:474) ~[camel-azure-2.19.2.jar:2.19.2]
at org.apache.camel.component.azure.blob.BlobServiceProducer.updateBlockBlob(BlobServiceProducer.java:143) ~[camel-azure-2.19.2.jar:2.19.2]
at org.apache.camel.component.azure.blob.BlobServiceProducer.process(BlobServiceProducer.java:79) ~[camel-azure-2.19.2.jar:2.19.2]**
我能够解决这个问题。我将路线改写为。
from("file://C:/camel/source1")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Object file = exchange.getIn().getMandatoryBody();
exchange.getOut().setBody(
GenericFileConverter.genericFileToInputStream(
(GenericFile<?>) file, exchange));
}
})
.to("azure-blob://datastorage/container1/BLOB1?credentials=#credentials&operation=updateBlockBlob")
.to("mock:Result");
我的问题是,我真的需要编写处理器吗?骆驼组件不应该接收流或文件对象吗?
【问题讨论】:
标签: apache-camel