camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pontus Ullgren <ullg...@gmail.com>
Subject Re: What is the best way to implement "RunLevel" equivalent functionality with camel.
Date Wed, 27 May 2015 09:01:22 GMT
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/
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message