使用具有 pollEnrich 模式的 apache camel 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 camel csv 处理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!