使用带有pollEnrich模式的apache骆驼csv处理器? [英] Using apache camel csv processor with pollEnrich pattern?
问题描述
Apache Camel 2.12.1
Apache Camel 2.12.1
是否可以将Camel CSV组件与pollEnrich一起使用?我看到的每个示例都像:
Is it possible to use the Camel CSV component with a pollEnrich? Every example I see is like:
from("file:somefile.csv").marshal...
我正在使用pollEnrich,例如:
Whereas I'm using the pollEnrich, like:
pollEnrich("file:somefile.csv", new CSVAggregator())
所以在CSVAggregator中我没有csv ...我只有一个文件,我必须自己进行csv处理.那么是否有某种方式可以将编组信息连接到丰富的地方...?
So within CSVAggregator I have no csv...I just have a file, which I have to do csv processing myself. So is there a way of hooking up the marshalling to the enrich bit somehow...?
编辑
要使其更通用...例如:
To make this more general... eg:
from("direct:start")
.to("http:www.blah")
.enrich("file:someFile.csv", new CSVAggregationStrategy) <--how can I call marshal() on this?
...
public class CSVAggregator implements AggregationStrategy {
@Override
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
/* Here I have:
oldExchange = results of http blah endpoint
newExchange = the someFile.csv GenericFile object */
}
有什么办法可以避免这种情况,并在路线本身上使用marshal().csv调用吗?
Is there any way I can avoid this and use marshal().csv sort of call on the route itself?
谢谢
茶先生
推荐答案
您可以使用任何端点来丰富功能.这包括指向其他路由的直接端点.你的例子...
You can use any endpoint in enrich. That includes direct endpoints pointing to other routes. Your example...
替换此:
from("direct:start")
.to("http:www.blah")
.enrich("file:someFile.csv", new CSVAggregationStrategy)
与此:
from("direct:start")
.to("http:www.blah")
.enrich("direct:readSomeFile", new CSVAggregationStrategy);
from("direct:readSomeFile")
.to("file:someFile.csv")
.unmarshal(myDataFormat);
这篇关于使用带有pollEnrich模式的apache骆驼csv处理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!