I want to build a camel route programmatically...

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

I want to build a camel route programmatically...

e0richt
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?
Reply | Threaded
Open this post in threaded view
|

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

Christian Mueller
Administrator
Checkout this link: http://camel.apache.org/running-camel-standalone.html

Best,
Christian

On Fri, Sep 14, 2012 at 6:50 PM, e0richt <[hidden email]> 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.
>



--
Reply | Threaded
Open this post in threaded view
|

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

Donald Whytock
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
<[hidden email]> wrote:

> Checkout this link: http://camel.apache.org/running-camel-standalone.html
>
> Best,
> Christian
>
> On Fri, Sep 14, 2012 at 6:50 PM, e0richt <[hidden email]> 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.
>>
>
>
>
> --
Reply | Threaded
Open this post in threaded view
|

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

e0richt
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...





Reply | Threaded
Open this post in threaded view
|

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

Claus Ibsen-2
On Sat, Sep 15, 2012 at 2:43 AM, e0richt <[hidden email]> 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: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen