It looks like your Predicate is a static now, which cannot take the message header as parameter. Please take a look at the Bean Language[1], it shows you how to write a right one.
[1]http://camel.apache.org/bean-language.html -- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (English) http://jnn.iteye.com (Chinese) Twitter: willemjiang Weibo: 姜宁willem On May 25, 2015 at 3:33:38 PM, Kondalarv (kondala.sou...@gmail.com) wrote: > I have choice with many options, and using java operation for conditions. > The route is going to otherwise() option always and checckFilePattern() > method is not executing. > > > from(FILE_WATCHER_DSL) > .log(LoggingLevel.INFO, FileWatchDSLUtil.getFileLogPattern()) > .choice() > > .when(checckFilePattern(header("CamelFileAbsolutePath").toString())).process(new > > FileConsumerProcesser()).endChoice() > .otherwise().log("File Patten is not Matched. ${file:absolute.path}") > .to("file:/app/work01/FileWatcherAgent/quarantine").process(new > FileConsumerErrorProcesser()).stop().endChoice() > .end() > .log("End Processing Route"); > ; > > > private static Predicate checckFilePattern(String fileName){ > logger.info("checckFilePattern==> File Name : {}", fileName); > boolean flag = false; > if(fileName.endsWith("txt")) flag= true; > Predicate predicate = PredicateBuilder.constant(flag); > logger.info("checckFilePattern==> predicate: {}", predicate); > return predicate; > } > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Content-Based-Router-Java-DSL-is-not-working-tp5767440.html > > Sent from the Camel - Users mailing list archive at Nabble.com. >