Apache Camel 2.12.1
我有这样的路线设置:
public void configure() throws Exception {
from("direct:start")
.process(new AuthorizationHeaderProcessor(configureCreds()))
.to(httpSourceEndpoint)
.process(new GenerateSQLFromMessageProcessor))
.enrich("jdbc:dataSource", new DBAggregator())
//...do things with result...
1)HttpSourceEndPoint是来自某个url的get请求 .
2)然后我想使用它的结果根据GenerateSQLFromMessageProcessor生成SQL,它作为JDBC路由的输入提供 .
我的问题是,在DBAggregator中,通过的参数是:
oldExchange = the raw SQL string that was sent to the JDBC call
newExchange = the result set from the DB query
即没有来自http源 endpoints 的原始消息的迹象,这就是我期望聚合工作的方式 . 我该如何组合2个流?它是使用原始消息的GenerateSQLFromMessageProcessor调用吗?如果是这样,你应该在bean中指定SQL来进行丰富吗?
EDIT
所以在 Headers 中设置如下:
public void configure() throws Exception {
from("direct:start")
.process(new AuthorizationHeaderProcessor(configureCreds()))
.to(httpSourceEndpoint)
.setHeader(new BeanExpression(MySQLBean.class, "methodToGenerateSQL")
.enrich("jdbc:dataSource", new DBAggregator())
//...do things with result...
结果我的聚合器看起来像这样:
public class DBAggregator implements AggregationStrategy {
@Override
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
Here I have:
oldExchange = the resulting SQL string that methodToGenerateSQL generated
newExchange = the result set from the SQL query
The problem is I do not have access to the original message that came from httpSourceEndpoint .
由于这是一个聚合器,我原本期望oldExchange是传入消息,而不仅仅是一个SQL字符串 . 毕竟,它是一个聚合器,但我已经有效地丢失了传入的消息 - 这不是“丰富”!
谢谢,茶先生