camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: What is the best way to implement "RunLevel" equivalent functionality with camel.
Date Wed, 27 May 2015 12:44:29 GMT
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 <ullgren@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 <claus.ibsen@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
>> <zolyfarkas@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 <hekonsek@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
>> >> <zolyfarkas@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/

Mime
View raw message