代码之家  ›  专栏  ›  技术社区  ›  Jigar Naik

骆驼+豆角

  •  1
  • Jigar Naik  · 技术社区  · 7 年前

    我该如何在阿帕奇骆驼中使用豆类的pollenrich?

    我尝试使用它,但得到了“您不能从bean端点消费”的部分。在本例中,我调用RESTAPI,但客户机提供了JAR文件,所以我需要调用bean并获取更多信息。

    from("quartz2://tsTimer?cron=" + cron + "&trigger.timeZone=" + timezone)
            .bean(tradingService)
            .process(new Processor() {
                @Override
                public void process(Exchange exchange) throws Exception {
                    exchange.setProperty("fileName","input-"  + dateFormat.format(new Date()) + ".xml");
                }
            })
            .pollEnrich("bean:tradingService", new AggregationStrategy() {
    
                @Override
                public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
                    System.out.println("oldExchange : " + oldExchange +" newExchange : " + newExchange);
                    return null;
                }
            })
            .marshal().jacksonxml(true)
            .wireTap("file:" + auditDir + "/?fileName=${header.fileName}")
            //split or merge
            .to("xslt:trans.xslt")
            .to(outQueue)
            .to("log:org.ts.tradingservice.camel?level=INFO&showBody=true")
            .end();
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   Claus Ibsen    7 年前

    只使用 enrich 用于生产方,如 enrich(...) . 如果需要的话你可以用它 合并 通过聚合策略将数据集中在一起。但是,如果您只想得到bean的结果/输出,那么使用一个普通的 to 相反,如果bean方法是 void 方法。