You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cmoulliard <cm...@gmail.com> on 2008/07/09 08:23:22 UTC

When().choice() & Filter() DSL not supported together !!

Hi,

I would lie to know why the following route cannot be configurated and if
there is a workaround ?

from("")
.choice()
.when.xpath("")
        .setHeader("name").xpath("")
        .filter().xquery("extract a part of the XML")
            .unmarshall()
        .to("queue:A")
        .end()
.otherwise().to("queue:B"); 

Regards,

charles
-- 
View this message in context: http://www.nabble.com/When%28%29.choice%28%29---Filter%28%29-DSL-not-supported-together-%21%21-tp18355221s22882p18355221.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: When().choice() & Filter() DSL not supported together !!

Posted by cmoulliard <cm...@gmail.com>.


Gert Vanthienen wrote:
> 
> Charles,
> 
> The end() method returns the raw ProcessorType.  You need a ChoiceType 
> in order to be able to access the otherwise() method.
> One option would be to assign the result of from("")....end() to a local 
> variable of type ChoiceType -- adding the necessary cast.  Afterwards, 
> you can add the otherwise().  Somthing like:
>   ChoiceType choice = (ChoiceType) 
> from("").choice().when()....to("queue:A").end();
>   choice.otherwise.to("queue:A")
> 
> Another option would be to extract the routing logic for the first 
> when() clause in a separate route (starting with e.g. a direct: style 
> endpoint) and just code 
> when().xpath().to("direct:when1").otherwise().to("queue:B").
> 
> We are currently adding a Scala DSL, which will allow you to use {} to 
> explicitly define the blocks in your routes (have a look at 
> http://activemq.apache.org/camel/scala-dsl-eip.html for some examples).
> 
> Regards,
> 
> Gert
> 
> cmoulliard wrote:
>> Hi,
>>
>> I would lie to know why the following route cannot be configurated and if
>> there is a workaround ?
>>
>> from("")
>> .choice()
>> .when.xpath("")
>>         .setHeader("name").xpath("")
>>         .filter().xquery("extract a part of the XML")
>>             .unmarshall()
>>         .to("queue:A")
>>         .end()
>> .otherwise().to("queue:B"); 
>>
>> Regards,
>>
>> charles
>>   
> 
> 
> 
> -----
> ---
> Gert Vanthienen
> http://www.anova.be
> 
:clap:
-- 
View this message in context: http://www.nabble.com/When%28%29.choice%28%29---Filter%28%29-DSL-not-supported-together-%21%21-tp18355221s22882p18356297.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: When().choice() & Filter() DSL not supported together !!

Posted by Gert Vanthienen <ge...@skynet.be>.
Charles,

The end() method returns the raw ProcessorType.  You need a ChoiceType 
in order to be able to access the otherwise() method.
One option would be to assign the result of from("")....end() to a local 
variable of type ChoiceType -- adding the necessary cast.  Afterwards, 
you can add the otherwise().  Somthing like:
  ChoiceType choice = (ChoiceType) 
from("").choice().when()....to("queue:A").end();
  choice.otherwise.to("queue:A")

Another option would be to extract the routing logic for the first 
when() clause in a separate route (starting with e.g. a direct: style 
endpoint) and just code 
when().xpath().to("direct:when1").otherwise().to("queue:B").

We are currently adding a Scala DSL, which will allow you to use {} to 
explicitly define the blocks in your routes (have a look at 
http://activemq.apache.org/camel/scala-dsl-eip.html for some examples).

Regards,

Gert

cmoulliard wrote:
> Hi,
>
> I would lie to know why the following route cannot be configurated and if
> there is a workaround ?
>
> from("")
> .choice()
> .when.xpath("")
>         .setHeader("name").xpath("")
>         .filter().xquery("extract a part of the XML")
>             .unmarshall()
>         .to("queue:A")
>         .end()
> .otherwise().to("queue:B"); 
>
> Regards,
>
> charles
>