You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by e0richt <e0...@yahoo.com> on 2012/09/14 18:50:21 UTC

I want to build a camel route programmatically...

Hi 


I am newbie with Camel and it seems to be very powerful framework. One thing
that I haven't found out yet is that how can you create routes
programmatically?
 
I want to do something like this:

camel = new DefaultCamelContext(); 

 camel.addRoutes(new RouteBuilder() { 
           @Override 
           public void configure() throws Exception { 
            
               from("file:C:\\FtpTestFolders\\FtpOut?delete=true") 
                       .setHeader(Exchange.FILE_NAME,
constant("TestiPrkl.txt"));
               for (int i=0; i<processorArrayList.length; i++) {
                       .processor(processorArrayList.get(i));
               }
               .to("file:C:\\FtpTestFolders\\FtpError"); 
            } 
        }); 

where can I find an example doing this?



--
View this message in context: http://camel.465427.n5.nabble.com/I-want-to-build-a-camel-route-programmatically-tp5719387.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: I want to build a camel route programmatically...

Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Sep 15, 2012 at 2:43 AM, e0richt <e0...@yahoo.com> wrote:
> ok, but I want to use the whole gamut of what is possible in camel during
> runtime.
> I have tried using the intermediate object shown by Eclipse but that
> definately did not work...
>
>
> given this:
>
>     from("....)
>         .to("......)
>         .filter("....")
>         .choice("....);
>
>
> there must be a way to do this:
>
>      objectX x = from("....");
>
>      x.to("......");
>      x.filter(".....");
>      x.choice("....");
>
>
> I just need to know what that "object" happens to be...
>

The Java DSL returns an object (ProcessorDefinition, RouteDefiniton) etc.

And you can keep a reference to that. And then continue with the DSL
using that instance.
For example from within your for loop.



>
>
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/I-want-to-build-a-camel-route-programmatically-tp5719387p5719400.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: I want to build a camel route programmatically...

Posted by e0richt <e0...@yahoo.com>.
ok, but I want to use the whole gamut of what is possible in camel during
runtime.
I have tried using the intermediate object shown by Eclipse but that
definately did not work... 


given this:

    from("....)
        .to("......)
        .filter("....")
        .choice("....);


there must be a way to do this:

     objectX x = from("....");

     x.to("......");
     x.filter(".....");
     x.choice("....");


I just need to know what that "object" happens to be... 









--
View this message in context: http://camel.465427.n5.nabble.com/I-want-to-build-a-camel-route-programmatically-tp5719387p5719400.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: I want to build a camel route programmatically...

Posted by Donald Whytock <dw...@gmail.com>.
You don't have to do the loop yourself.  You can use a Pipeline
processor, as described at

http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/Pipeline.html

Don

On Fri, Sep 14, 2012 at 5:14 PM, Christian Müller
<ch...@gmail.com> wrote:
> Checkout this link: http://camel.apache.org/running-camel-standalone.html
>
> Best,
> Christian
>
> On Fri, Sep 14, 2012 at 6:50 PM, e0richt <e0...@yahoo.com> wrote:
>
>> Hi
>>
>>
>> I am newbie with Camel and it seems to be very powerful framework. One
>> thing
>> that I haven't found out yet is that how can you create routes
>> programmatically?
>>
>> I want to do something like this:
>>
>> camel = new DefaultCamelContext();
>>
>>  camel.addRoutes(new RouteBuilder() {
>>            @Override
>>            public void configure() throws Exception {
>>
>>                from("file:C:\\FtpTestFolders\\FtpOut?delete=true")
>>                        .setHeader(Exchange.FILE_NAME,
>> constant("TestiPrkl.txt"));
>>                for (int i=0; i<processorArrayList.length; i++) {
>>                        .processor(processorArrayList.get(i));
>>                }
>>                .to("file:C:\\FtpTestFolders\\FtpError");
>>             }
>>         });
>>
>> where can I find an example doing this?
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/I-want-to-build-a-camel-route-programmatically-tp5719387.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>
>
> --

Re: I want to build a camel route programmatically...

Posted by Christian Müller <ch...@gmail.com>.
Checkout this link: http://camel.apache.org/running-camel-standalone.html

Best,
Christian

On Fri, Sep 14, 2012 at 6:50 PM, e0richt <e0...@yahoo.com> wrote:

> Hi
>
>
> I am newbie with Camel and it seems to be very powerful framework. One
> thing
> that I haven't found out yet is that how can you create routes
> programmatically?
>
> I want to do something like this:
>
> camel = new DefaultCamelContext();
>
>  camel.addRoutes(new RouteBuilder() {
>            @Override
>            public void configure() throws Exception {
>
>                from("file:C:\\FtpTestFolders\\FtpOut?delete=true")
>                        .setHeader(Exchange.FILE_NAME,
> constant("TestiPrkl.txt"));
>                for (int i=0; i<processorArrayList.length; i++) {
>                        .processor(processorArrayList.get(i));
>                }
>                .to("file:C:\\FtpTestFolders\\FtpError");
>             }
>         });
>
> where can I find an example doing this?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/I-want-to-build-a-camel-route-programmatically-tp5719387.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--