【问题标题】:Camel + pollEnrich from beanCamel + pollEnrich from bean
【发布时间】:2019-02-11 10:41:33
【问题描述】:

如何在 Apache Camel 中将 pollEnrich 与 Bean 一起使用?

我尝试使用它,但在这种情况下得到“你不能从 bean 端点消费”的异常,我正在调用 rest api 但客户端提供了 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();

【问题讨论】:

    标签: apache-camel


    【解决方案1】:

    只需使用enrich,它用于使用生产者端,例如enrich(...)。如果您需要通过聚合策略将数据合并在一起,则可以使用它。但是,如果您只想获取 bean 的结果/输出,则使用普通的 to 代替,如果 bean 方法是 void 方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-06
      • 1970-01-01
      • 2016-11-01
      • 2014-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-11
      相关资源
      最近更新 更多