You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Zoltan Farkas <zo...@yahoo.com.INVALID> on 2015/05/26 02:22:38 UTC

What is the best way to implement "RunLevel" equivalent functionality with camel.

I want to be able in implement similar functionality like unix run levels ..

level 1 - start level 1 set of routes
level 2 - run all from level 1 + level 2 specific routes.
...

I want to be able to go from level 1 -> level 2 and vice versa. (starting/stopping the necessary routes..)

What would be the best way to implement this? Currently I am leaning towards using different camel contexts for each level…

Any help appreciated

thank you

—Z

Re: What is the best way to implement "RunLevel" equivalent functionality with camel.

Posted by Pontus Ullgren <ul...@gmail.com>.
I agree with you Claus. In our special case we used the extra meta data to
be able to start and stop all routes belonging to the same group when a new
definition, version, is published.

But as you say since the logic depends on very specific use cases I do not
see any real reason for adding this to the dsl. As it is very easy to
achieve using the existing public api.

For the original run level request one might simply add a run level
property to the route, using a custom route policy, and then loop through
all routes and start them in the correct order.

Or, as already been mentioned, use the depends on feature.

On Wed, 27 May 2015 14:45 Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> There is no official way. Well all is the official way if using the public
> api.
>
> Storing those kind of meta-data hasn't been requested much in the
> community and therefore hasn't been exposed in the DSL. We tend to
> avoid adding to much to the DSL, unless its useable and needed by
> average use-cases.
>
> Most people just need to provide a id of the route and an optional
> description. Also those meta-data are not integrated with other parts
> such as EIPs, et all so they wont be so useable.
>
> One meta-data that never was so much exposes was the idea of
> associating a group to routes. So you could do bulk operations on a
> group. Though that may require expose group level operations in JMX
> and Karaf commands and whatnot so they can easily be used from
> operations pov. Things  tend to further complicate a bit if eg
> starting a group, and then 1 route fails, what should happen then?
>
>
>
>
>
> On Wed, May 27, 2015 at 11:01 AM, Pontus Ullgren <ul...@gmail.com>
> wrote:
> > I'm sure this is not the way it was intended but I have in the past used
> a
> > custom RoutePolicy that includes the custom properties and attached this
> to
> > the route.
> > In the onInit(Route) method of this RoutePolicy we then set the
> properties
> > in the route.
> >
> > class FileRouteVersionPolicy extends RoutePolicySupport {
> >         final String  group;
> >         final Integer version;
> >
> >         public FileRouteVersionPolicy(String group, Integer version) {
> >             this.group = group;
> >             this.version = version;
> >         }
> >
> >         @Override
> >         public void onInit(Route route) {
> >             route.getProperties().put("group", group);
> >             route.getProperties().put("version", version);
> >
> >             super.onInit(route);
> >         }
> >     }
> >
> > FileRouteVersionPolicy frvp = new FileRouteVersionPolicy();
> > frvp.put("someproperty", "value");
> >
> > from(input)
> >   .routeId("myroute")
> >   .routePolicy(frvp)
> >   .to("direct:dosomething");
> >
> > Then when you can get the route based on routeId and access the route
> > properties.
> >
> > Again I'm not sure that this is a officially supported way of doing
> things
> > but it seems to work in that application :-)
> >
> > // Pontus
> >
> > On Wed, 27 May 2015 at 07:31 Claus Ibsen <cl...@gmail.com> wrote:
> >
> >> Hi
> >>
> >> You can use .description to set a route description.
> >> But there is no key/value map that you can associate to a route.
> >>
> >> You could also look at startup order and assign 1xx for level 1, 2xx
> >> for level 2, etc.
> >>
> >>
> http://camel.apache.org/configuring-route-startup-ordering-and-autostartup.html
> >>
> >> On Tue, May 26, 2015 at 9:10 PM, Zoltan Farkas
> >> <zo...@yahoo.com.invalid> wrote:
> >> > Thank you,
> >> >
> >> > is there a way to attach some metadata(attributes) to a camel route?
> >> >
> >> >
> >> > —Z
> >> >
> >> >
> >> >
> >> >> On May 26, 2015, at 3:48 AM, Henryk Konsek <he...@gmail.com>
> wrote:
> >> >>
> >> >> Hi Zoltan,
> >> >>
> >> >> You can use splitter with conjunction with the Control Bus [1] to
> >> achieve
> >> >> this.
> >> >>
> >> >> from("direct:splitAndStart").
> >> >>  split().body().setHeader("routeId", body()
> >> >> ).to("controlbus:route?&action=start");
> >> >>
> >> >> from("direct:startLevel1").
> >> >>  setBody().constant(Arrays.asList("route1", "route2")).
> >> >>  to("direct:splitAndStart");
> >> >>
> >> >> from("direct:startLevel2").
> >> >>  to("direct:startLevel1").
> >> >>  setBody().constant(Arrays.asList("route3", "route4")).
> >> >>  to("direct:splitAndStart");
> >> >>
> >> >> Cheers!
> >> >>
> >> >> [1] http://camel.apache.org/controlbus.html
> >> >>
> >> >> wt., 26.05.2015 o 02:24 użytkownik Zoltan Farkas
> >> >> <zo...@yahoo.com.invalid> napisał:
> >> >>
> >> >>> I want to be able in implement similar functionality like unix run
> >> levels
> >> >>> ..
> >> >>>
> >> >>> level 1 - start level 1 set of routes
> >> >>> level 2 - run all from level 1 + level 2 specific routes.
> >> >>> ...
> >> >>>
> >> >>> I want to be able to go from level 1 -> level 2 and vice versa.
> >> >>> (starting/stopping the necessary routes..)
> >> >>>
> >> >>> What would be the best way to implement this? Currently I am leaning
> >> >>> towards using different camel contexts for each level…
> >> >>>
> >> >>> Any help appreciated
> >> >>>
> >> >>> thank you
> >> >>>
> >> >>> —Z
> >> >
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> -----------------
> >> Red Hat, Inc.
> >> Email: cibsen@redhat.com
> >> Twitter: davsclaus
> >> Blog: http://davsclaus.com
> >> Author of Camel in Action: http://www.manning.com/ibsen
> >> hawtio: http://hawt.io/
> >> fabric8 <http://hawt.io/fabric8>: http://fabric8.io/
> >>
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8 <http://hawt.io/fabric8>: http://fabric8.io/
>

Re: What is the best way to implement "RunLevel" equivalent functionality with camel.

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

There is no official way. Well all is the official way if using the public api.

Storing those kind of meta-data hasn't been requested much in the
community and therefore hasn't been exposed in the DSL. We tend to
avoid adding to much to the DSL, unless its useable and needed by
average use-cases.

Most people just need to provide a id of the route and an optional
description. Also those meta-data are not integrated with other parts
such as EIPs, et all so they wont be so useable.

One meta-data that never was so much exposes was the idea of
associating a group to routes. So you could do bulk operations on a
group. Though that may require expose group level operations in JMX
and Karaf commands and whatnot so they can easily be used from
operations pov. Things  tend to further complicate a bit if eg
starting a group, and then 1 route fails, what should happen then?





On Wed, May 27, 2015 at 11:01 AM, Pontus Ullgren <ul...@gmail.com> wrote:
> I'm sure this is not the way it was intended but I have in the past used a
> custom RoutePolicy that includes the custom properties and attached this to
> the route.
> In the onInit(Route) method of this RoutePolicy we then set the properties
> in the route.
>
> class FileRouteVersionPolicy extends RoutePolicySupport {
>         final String  group;
>         final Integer version;
>
>         public FileRouteVersionPolicy(String group, Integer version) {
>             this.group = group;
>             this.version = version;
>         }
>
>         @Override
>         public void onInit(Route route) {
>             route.getProperties().put("group", group);
>             route.getProperties().put("version", version);
>
>             super.onInit(route);
>         }
>     }
>
> FileRouteVersionPolicy frvp = new FileRouteVersionPolicy();
> frvp.put("someproperty", "value");
>
> from(input)
>   .routeId("myroute")
>   .routePolicy(frvp)
>   .to("direct:dosomething");
>
> Then when you can get the route based on routeId and access the route
> properties.
>
> Again I'm not sure that this is a officially supported way of doing things
> but it seems to work in that application :-)
>
> // Pontus
>
> On Wed, 27 May 2015 at 07:31 Claus Ibsen <cl...@gmail.com> wrote:
>
>> Hi
>>
>> You can use .description to set a route description.
>> But there is no key/value map that you can associate to a route.
>>
>> You could also look at startup order and assign 1xx for level 1, 2xx
>> for level 2, etc.
>>
>> http://camel.apache.org/configuring-route-startup-ordering-and-autostartup.html
>>
>> On Tue, May 26, 2015 at 9:10 PM, Zoltan Farkas
>> <zo...@yahoo.com.invalid> wrote:
>> > Thank you,
>> >
>> > is there a way to attach some metadata(attributes) to a camel route?
>> >
>> >
>> > —Z
>> >
>> >
>> >
>> >> On May 26, 2015, at 3:48 AM, Henryk Konsek <he...@gmail.com> wrote:
>> >>
>> >> Hi Zoltan,
>> >>
>> >> You can use splitter with conjunction with the Control Bus [1] to
>> achieve
>> >> this.
>> >>
>> >> from("direct:splitAndStart").
>> >>  split().body().setHeader("routeId", body()
>> >> ).to("controlbus:route?&action=start");
>> >>
>> >> from("direct:startLevel1").
>> >>  setBody().constant(Arrays.asList("route1", "route2")).
>> >>  to("direct:splitAndStart");
>> >>
>> >> from("direct:startLevel2").
>> >>  to("direct:startLevel1").
>> >>  setBody().constant(Arrays.asList("route3", "route4")).
>> >>  to("direct:splitAndStart");
>> >>
>> >> Cheers!
>> >>
>> >> [1] http://camel.apache.org/controlbus.html
>> >>
>> >> wt., 26.05.2015 o 02:24 użytkownik Zoltan Farkas
>> >> <zo...@yahoo.com.invalid> napisał:
>> >>
>> >>> I want to be able in implement similar functionality like unix run
>> levels
>> >>> ..
>> >>>
>> >>> level 1 - start level 1 set of routes
>> >>> level 2 - run all from level 1 + level 2 specific routes.
>> >>> ...
>> >>>
>> >>> I want to be able to go from level 1 -> level 2 and vice versa.
>> >>> (starting/stopping the necessary routes..)
>> >>>
>> >>> What would be the best way to implement this? Currently I am leaning
>> >>> towards using different camel contexts for each level…
>> >>>
>> >>> Any help appreciated
>> >>>
>> >>> thank you
>> >>>
>> >>> —Z
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> Email: cibsen@redhat.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>> hawtio: http://hawt.io/
>> fabric8 <http://hawt.io/fabric8>: http://fabric8.io/
>>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: What is the best way to implement "RunLevel" equivalent functionality with camel.

Posted by Pontus Ullgren <ul...@gmail.com>.
I'm sure this is not the way it was intended but I have in the past used a
custom RoutePolicy that includes the custom properties and attached this to
the route.
In the onInit(Route) method of this RoutePolicy we then set the properties
in the route.

class FileRouteVersionPolicy extends RoutePolicySupport {
        final String  group;
        final Integer version;

        public FileRouteVersionPolicy(String group, Integer version) {
            this.group = group;
            this.version = version;
        }

        @Override
        public void onInit(Route route) {
            route.getProperties().put("group", group);
            route.getProperties().put("version", version);

            super.onInit(route);
        }
    }

FileRouteVersionPolicy frvp = new FileRouteVersionPolicy();
frvp.put("someproperty", "value");

from(input)
  .routeId("myroute")
  .routePolicy(frvp)
  .to("direct:dosomething");

Then when you can get the route based on routeId and access the route
properties.

Again I'm not sure that this is a officially supported way of doing things
but it seems to work in that application :-)

// Pontus

On Wed, 27 May 2015 at 07:31 Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> You can use .description to set a route description.
> But there is no key/value map that you can associate to a route.
>
> You could also look at startup order and assign 1xx for level 1, 2xx
> for level 2, etc.
>
> http://camel.apache.org/configuring-route-startup-ordering-and-autostartup.html
>
> On Tue, May 26, 2015 at 9:10 PM, Zoltan Farkas
> <zo...@yahoo.com.invalid> wrote:
> > Thank you,
> >
> > is there a way to attach some metadata(attributes) to a camel route?
> >
> >
> > —Z
> >
> >
> >
> >> On May 26, 2015, at 3:48 AM, Henryk Konsek <he...@gmail.com> wrote:
> >>
> >> Hi Zoltan,
> >>
> >> You can use splitter with conjunction with the Control Bus [1] to
> achieve
> >> this.
> >>
> >> from("direct:splitAndStart").
> >>  split().body().setHeader("routeId", body()
> >> ).to("controlbus:route?&action=start");
> >>
> >> from("direct:startLevel1").
> >>  setBody().constant(Arrays.asList("route1", "route2")).
> >>  to("direct:splitAndStart");
> >>
> >> from("direct:startLevel2").
> >>  to("direct:startLevel1").
> >>  setBody().constant(Arrays.asList("route3", "route4")).
> >>  to("direct:splitAndStart");
> >>
> >> Cheers!
> >>
> >> [1] http://camel.apache.org/controlbus.html
> >>
> >> wt., 26.05.2015 o 02:24 użytkownik Zoltan Farkas
> >> <zo...@yahoo.com.invalid> napisał:
> >>
> >>> I want to be able in implement similar functionality like unix run
> levels
> >>> ..
> >>>
> >>> level 1 - start level 1 set of routes
> >>> level 2 - run all from level 1 + level 2 specific routes.
> >>> ...
> >>>
> >>> I want to be able to go from level 1 -> level 2 and vice versa.
> >>> (starting/stopping the necessary routes..)
> >>>
> >>> What would be the best way to implement this? Currently I am leaning
> >>> towards using different camel contexts for each level…
> >>>
> >>> Any help appreciated
> >>>
> >>> thank you
> >>>
> >>> —Z
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8 <http://hawt.io/fabric8>: http://fabric8.io/
>

Re: What is the best way to implement "RunLevel" equivalent functionality with camel.

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

You can use .description to set a route description.
But there is no key/value map that you can associate to a route.

You could also look at startup order and assign 1xx for level 1, 2xx
for level 2, etc.
http://camel.apache.org/configuring-route-startup-ordering-and-autostartup.html

On Tue, May 26, 2015 at 9:10 PM, Zoltan Farkas
<zo...@yahoo.com.invalid> wrote:
> Thank you,
>
> is there a way to attach some metadata(attributes) to a camel route?
>
>
> —Z
>
>
>
>> On May 26, 2015, at 3:48 AM, Henryk Konsek <he...@gmail.com> wrote:
>>
>> Hi Zoltan,
>>
>> You can use splitter with conjunction with the Control Bus [1] to achieve
>> this.
>>
>> from("direct:splitAndStart").
>>  split().body().setHeader("routeId", body()
>> ).to("controlbus:route?&action=start");
>>
>> from("direct:startLevel1").
>>  setBody().constant(Arrays.asList("route1", "route2")).
>>  to("direct:splitAndStart");
>>
>> from("direct:startLevel2").
>>  to("direct:startLevel1").
>>  setBody().constant(Arrays.asList("route3", "route4")).
>>  to("direct:splitAndStart");
>>
>> Cheers!
>>
>> [1] http://camel.apache.org/controlbus.html
>>
>> wt., 26.05.2015 o 02:24 użytkownik Zoltan Farkas
>> <zo...@yahoo.com.invalid> napisał:
>>
>>> I want to be able in implement similar functionality like unix run levels
>>> ..
>>>
>>> level 1 - start level 1 set of routes
>>> level 2 - run all from level 1 + level 2 specific routes.
>>> ...
>>>
>>> I want to be able to go from level 1 -> level 2 and vice versa.
>>> (starting/stopping the necessary routes..)
>>>
>>> What would be the best way to implement this? Currently I am leaning
>>> towards using different camel contexts for each level…
>>>
>>> Any help appreciated
>>>
>>> thank you
>>>
>>> —Z
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: What is the best way to implement "RunLevel" equivalent functionality with camel.

Posted by Mark Frazier <mm...@me.com>.
You can put them in the exchange headers.

> On May 26, 2015, at 12:10 PM, Zoltan Farkas <zo...@yahoo.com.INVALID> wrote:
> 
> Thank you, 
> 
> is there a way to attach some metadata(attributes) to a camel route?
> 
> 
> —Z
> 
> 
> 
>> On May 26, 2015, at 3:48 AM, Henryk Konsek <he...@gmail.com> wrote:
>> 
>> Hi Zoltan,
>> 
>> You can use splitter with conjunction with the Control Bus [1] to achieve
>> this.
>> 
>> from("direct:splitAndStart").
>> split().body().setHeader("routeId", body()
>> ).to("controlbus:route?&action=start");
>> 
>> from("direct:startLevel1").
>> setBody().constant(Arrays.asList("route1", "route2")).
>> to("direct:splitAndStart");
>> 
>> from("direct:startLevel2").
>> to("direct:startLevel1").
>> setBody().constant(Arrays.asList("route3", "route4")).
>> to("direct:splitAndStart");
>> 
>> Cheers!
>> 
>> [1] http://camel.apache.org/controlbus.html
>> 
>> wt., 26.05.2015 o 02:24 użytkownik Zoltan Farkas
>> <zo...@yahoo.com.invalid> napisał:
>> 
>>> I want to be able in implement similar functionality like unix run levels
>>> ..
>>> 
>>> level 1 - start level 1 set of routes
>>> level 2 - run all from level 1 + level 2 specific routes.
>>> ...
>>> 
>>> I want to be able to go from level 1 -> level 2 and vice versa.
>>> (starting/stopping the necessary routes..)
>>> 
>>> What would be the best way to implement this? Currently I am leaning
>>> towards using different camel contexts for each level…
>>> 
>>> Any help appreciated
>>> 
>>> thank you
>>> 
>>> —Z
> 


Re: What is the best way to implement "RunLevel" equivalent functionality with camel.

Posted by Zoltan Farkas <zo...@yahoo.com.INVALID>.
Thank you, 

is there a way to attach some metadata(attributes) to a camel route?


—Z



> On May 26, 2015, at 3:48 AM, Henryk Konsek <he...@gmail.com> wrote:
> 
> Hi Zoltan,
> 
> You can use splitter with conjunction with the Control Bus [1] to achieve
> this.
> 
> from("direct:splitAndStart").
>  split().body().setHeader("routeId", body()
> ).to("controlbus:route?&action=start");
> 
> from("direct:startLevel1").
>  setBody().constant(Arrays.asList("route1", "route2")).
>  to("direct:splitAndStart");
> 
> from("direct:startLevel2").
>  to("direct:startLevel1").
>  setBody().constant(Arrays.asList("route3", "route4")).
>  to("direct:splitAndStart");
> 
> Cheers!
> 
> [1] http://camel.apache.org/controlbus.html
> 
> wt., 26.05.2015 o 02:24 użytkownik Zoltan Farkas
> <zo...@yahoo.com.invalid> napisał:
> 
>> I want to be able in implement similar functionality like unix run levels
>> ..
>> 
>> level 1 - start level 1 set of routes
>> level 2 - run all from level 1 + level 2 specific routes.
>> ...
>> 
>> I want to be able to go from level 1 -> level 2 and vice versa.
>> (starting/stopping the necessary routes..)
>> 
>> What would be the best way to implement this? Currently I am leaning
>> towards using different camel contexts for each level…
>> 
>> Any help appreciated
>> 
>> thank you
>> 
>> —Z


Re: What is the best way to implement "RunLevel" equivalent functionality with camel.

Posted by Henryk Konsek <he...@gmail.com>.
Hi Zoltan,

You can use splitter with conjunction with the Control Bus [1] to achieve
this.

from("direct:splitAndStart").
  split().body().setHeader("routeId", body()
).to("controlbus:route?&action=start");

from("direct:startLevel1").
  setBody().constant(Arrays.asList("route1", "route2")).
  to("direct:splitAndStart");

from("direct:startLevel2").
  to("direct:startLevel1").
  setBody().constant(Arrays.asList("route3", "route4")).
  to("direct:splitAndStart");

Cheers!

[1] http://camel.apache.org/controlbus.html

wt., 26.05.2015 o 02:24 użytkownik Zoltan Farkas
<zo...@yahoo.com.invalid> napisał:

> I want to be able in implement similar functionality like unix run levels
> ..
>
> level 1 - start level 1 set of routes
> level 2 - run all from level 1 + level 2 specific routes.
> ...
>
> I want to be able to go from level 1 -> level 2 and vice versa.
> (starting/stopping the necessary routes..)
>
> What would be the best way to implement this? Currently I am leaning
> towards using different camel contexts for each level…
>
> Any help appreciated
>
> thank you
>
> —Z