Jigar Naik
Jigar Naik

Reputation: 1994

Camel + pollEnrich from bean

How do i use pollEnrich with Bean in Apache Camel?

I tried using this but getting excetion "You cannot consume from a bean endpoint" in this case, i am calling rest api but client has provided jar file so i need to call bean and get additional information.

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();

Upvotes: 1

Views: 484

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 56082

Just use enrich which is for using the producer side, eg enrich(...). You can use that if you need to merge the data together via the aggregation strategy. However if you just want to result/output of the bean then use a plain to instead, of if the bean method is a void method.

Upvotes: 3

Related Questions