You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by furchess123 <co...@hotmail.com> on 2015/08/06 17:51:45 UTC

DSL to dynamically enable/disable parallelProcessing?

Hi,
I am using a splitter to read a file. The definition looks something like
this:


           split().
                tokenize(System.lineSeparator(),
readerConfig.getLinesPerChunk()).
                streaming().             
                parallelProcessing(). 
                bean(myProcessor).    
                ...
            end();      


Including  ".parallelProcessing()" in the split definition unequivocally
enables multithreading. But what if I want to enable or disable parallel
processing depending on an external configuration property? What is the best
way to do it in Java DSL? Do I have to use choice().when() etc? Or is there
a better, more elegant way?  I know the SplitDefinition class has the
setParallelProcessing(boolean) method. But I am not clear on how I can use
it in the DSL configuration?

Thanks!




--
View this message in context: http://camel.465427.n5.nabble.com/DSL-to-dynamically-enable-disable-parallelProcessing-tp5770389.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: DSL to dynamically enable/disable parallelProcessing?

Posted by furchess123 <co...@hotmail.com>.
Thanks, Claus. So, this will be available in 2.16.x. In the meantime, do you
mind providing a working example of how to use conditional DSL?  I have
tried something like this, which didn't work:

         split(). 
                 tokenize(System.lineSeparator(), 
readerConfig.getLinesPerChunk()). 
                 streaming(). 
                 
*                 choice().
                      when(...my condition predicate...).
                          parallelProcessing().
                 endChoice().
 *
                 bean(myProcessor). 
                 ... 
         end(); 

This doesn't work for the obvious reason: whatever precedes
"parallelProcessing()" must return a SplitDefinition, not
ChoiceDefinition(). So, how do we enable parallel processing in DSL
conditionally?

Thanks,
Constantine



--
View this message in context: http://camel.465427.n5.nabble.com/DSL-to-dynamically-enable-disable-parallelProcessing-tp5770389p5770433.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: DSL to dynamically enable/disable parallelProcessing?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah we can do this more easier in the future. I have logged a ticket
https://issues.apache.org/jira/browse/CAMEL-9061


On Thu, Aug 6, 2015 at 5:51 PM, furchess123 <co...@hotmail.com> wrote:
> Hi,
> I am using a splitter to read a file. The definition looks something like
> this:
>
>
>            split().
>                 tokenize(System.lineSeparator(),
> readerConfig.getLinesPerChunk()).
>                 streaming().
>                 parallelProcessing().
>                 bean(myProcessor).
>                 ...
>             end();
>
>
> Including  ".parallelProcessing()" in the split definition unequivocally
> enables multithreading. But what if I want to enable or disable parallel
> processing depending on an external configuration property? What is the best
> way to do it in Java DSL? Do I have to use choice().when() etc? Or is there
> a better, more elegant way?  I know the SplitDefinition class has the
> setParallelProcessing(boolean) method. But I am not clear on how I can use
> it in the DSL configuration?
>
> Thanks!
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/DSL-to-dynamically-enable-disable-parallelProcessing-tp5770389.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition: http://www.manning.com/ibsen2