我已经写了骆驼路线其轮询的文件夹,并将其发送到天青斑点集装箱骆驼天青BlobServiceProducer抛出:IllegalArgumentException:不支持的BLOB类型:org.apache.camel.component.file.GenericFile
我随后提到的示例在Azure文档页面中 https://github.com/apache/camel/blob/master/components/camel-azure/src/main/docs/azure-blob-component.adoc
我正在倒转路线。我使用的是Azure Blob Producer,而不是消费者。 这是我的路线。我已经使用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");
我的问题是,我需要真的写处理器吗?骆驼组件不应该接收流或文件对象吗?
有没有一种方法,我可以做到这一点通过一个拦截器?我尝试过,但我有多个路线,其中我列出blob并更新blob。只有当它是一个azure blob和操作=更新时才想做。猜猜可能需要使用一些正则表达式来做 – pointerness
你可以使用interceptSendToEndpoint(“azure *”),然后添加covertBodyTo。详情请参阅:http://camel.apache.org/intercept –
这是否会导致任何性能问题?因为我需要将它发送到天蓝色,我认为使用分离器不会帮助正确。对不起,我要关闭主题 – pointerness