I'm not sure if end() will help (not in every case) as you could have
to cast to ChoiceType whatever is returned by end().
My solution to those problems was something like:
from(cnn).
choice().
when(xpath(filter)).to(direct:subflow).otherwise().to(direct:something-else);
from(direct:subflow).multicast().to(im, archive);
This way you cannot hit any 'class type' problem in your DSL.
Sometimes it could be important to add in your subflow something like
errorhandler(noErrorHandler()) so it will not have its own error
handler.
Roman
2008/8/7 Willem Jiang <[EMAIL PROTECTED]>:
> The end() means to close the block, just like the "}" in java, it is very
> useful for the choice() fluent API.
>
> Willem
>
> Louis Polycarpou wrote:
>>
>> Thanks. I'll try that. The multicast fluent builder example
>> http://activemq.apache.org/camel/multicast.html here doesn't use end:
>>
>> from("direct:a").multicast().to("direct:x", "direct:y", "direct:z");
>>
>> What's the difference between:
>>
>> multicast().to("direct:x", "direct:y", "direct:z").end();
>> and
>>
>> to("direct:x", "direct:y", "direct:z");
>>
>> Thanks.
>>
>> Hadrian Zbarcea wrote:
>>
>>>
>>> Hi,
>>>
>>> Did you try end() to terminate the multicast? As in:
>>> from(uri).
>>> choice().
>>> when(expr).multicast().to(uris).end().
>>> otherwise().to(pojo);
>>>
>>> Cheers
>>> Hadrian
>>>
>>>
>>> On Aug 6, 2008, at 8:28 PM, Louis Polycarpou wrote:
>>>
>>>
>>>>
>>>> Louis Polycarpou wrote:
>>>>
>>>>>
>>>>> I'm trying to broadcast a feed to multiple endpoints but with
>>>>> content-based selection. I assume I need to use multicast, however, I
>>>>> can't achieve conditional multicast based on content selection since I
>>>>> can't use an otherwise() method after using
>>>>> multicast().to("endpoint1",
>>>>> "endpoint2")
>>>>>
>>>>> Furthermore, the to() method supports a list of endpoints without
>>>>> requiring a multicast first so what is the difference between that and
>>>>> a
>>>>> multicast().to(...)?
>>>>>
>>>>> feed in -> multicast to two outputs
>>>>>
>>>>> To recap with code:
>>>>>
>>>>> 1) I can't use otherwise after a multicast...
>>>>>
>>>>> from(cnn).
>>>>> choice().
>>>>> when(xpath(filter)).multicast().to(im, archive); // I
>>>>> can't now use otherwise()...
>>>>>
>>>>> 2) Do I really need multicast or can I just do the following...?
>>>>>
>>>>> from(cnn).
>>>>> choice().
>>>>> when(xpath(filter)).to(im, archive).
>>>>> otherwise().to(myPojo);
>>>>>
>>>>>
>>>>>
>>>>
>>>> One way I've worked around this is to inverse the filter and do the
>>>> multicast in the otherwise() part but clearly this doesn't answer my
>>>> original question:
>>>>
>>>> from(cnn).
>>>> choice().
>>>> when(xpath(filter)).to(stdout).
>>>> otherwise().multicast().to(im, archive);
>>>>
>>>> --
>>>> View this message in context:
>>>>
>>>> http://www.nabble.com/Multicast-with-choice-tp18861976s22882p18862033.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>>
>
>