You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by abhinavm <ab...@gmail.com> on 2013/10/23 17:46:08 UTC

endChoice() in Camel Scala DSL

Hello,

I have a scenario, where some code needs to go into choice, some in
otherwise, and some common clean-up code needs to be executed after that in
both scenarios. Since I could not find endChoice() or end() in the Scala
DSL, I tried the following piece of code, but could not achieve what I
wanted. Basically it would consider all the code after otherwise as a part
of otherwise. Can someone please tell me where I am going wrong ? 

      .choice(){
        when(exchange => exchange.getIn.getBody(classOf[String]) != null){
          process(new ResponseProcessor)
          .log(LoggingLevel.INFO,"File with content: ${body}")
          .log("Completed Job")
        } otherwise{
          log(LoggingLevel.INFO,"Empty Body")
        }
      }
      .log("Should Reach Here in all scenarios")


Thanks





--
View this message in context: http://camel.465427.n5.nabble.com/endChoice-in-Camel-Scala-DSL-tp5742094.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: endChoice() in Camel Scala DSL

Posted by Willem jiang <wi...@gmail.com>.
Hi
As Scala supports to passing a block, you don't need to use endChoice() or end() to close the choice() 
Here is an example for it
choice {
when(simple("${body} == 'foo'")) to "mock:foo"
otherwise to "mock:other"
}
to("mock:end")


-- 
Willem Jiang



On Wednesday, October 23, 2013 at 11:46 PM, abhinavm wrote:

> Hello,
> 
> I have a scenario, where some code needs to go into choice, some in
> otherwise, and some common clean-up code needs to be executed after that in
> both scenarios. Since I could not find endChoice() or end() in the Scala
> DSL, I tried the following piece of code, but could not achieve what I
> wanted. Basically it would consider all the code after otherwise as a part
> of otherwise. Can someone please tell me where I am going wrong ? 
> 
> .choice(){
> when(exchange => exchange.getIn.getBody(classOf[String]) != null){
> process(new ResponseProcessor)
> .log(LoggingLevel.INFO,"File with content: ${body}")
> .log("Completed Job")
> } otherwise{
> log(LoggingLevel.INFO,"Empty Body")
> }
> }
> .log("Should Reach Here in all scenarios")
> 
> 
> Thanks
> 
> 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/endChoice-in-Camel-Scala-DSL-tp5742094.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).