FAQ
Hi

I am struggling a bit with loading a custom
LifecycleManagementStrategy. (Like some previous posters I am looking
to load some xml routes on startup).

I have created a class DHIS2LifecycleManagementStrategy which extends
DefaultLifecycleManagementStrategy and overridden the onContextStart()
method. But I'm not sure what exactly to put in my spring beans
configuration file in order for this strategy to be picked up. I have
the following:

<!-- custom lifecycle strategy -->
<bean id="lifecyclestrategy" class="import
org.hisp.dhis.integration.management.DHIS2LifecycleManagementStrategy"
/>

<camel:context .... />

Any idea what I am missing?

Thanks
Bob

Search Discussions

  • Babak Vahdat at Apr 13, 2012 at 1:00 pm
    Hi

    You could look at [1] to see how easily you can add routes from XML, and
    check the commit log at the bottom of that link for some examples.

    You could also add routes dynamically at runtime [2] using Camel's JMX
    ManagedCamelContext MBean.

    [1] http://camel.apache.org/loading-routes-from-xml-files.html
    [2]
    http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/management/mbean/ManagedCamelContext.html#addOrUpdateRoutesFromXml(java.lang.String)

    Babak

    --
    View this message in context: http://camel.465427.n5.nabble.com/newbie-question-re-LifecycleManagementStrategy-tp5638024p5638219.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Bob Jolliffe at Apr 13, 2012 at 1:29 pm
    Thanks Babak for the suggestions. A few queries in line ...
    On 13 April 2012 14:00, Babak Vahdat wrote:
    Hi

    You could look at [1] to see how easily you can add routes from XML, and
    check the commit log at the bottom of that link for some examples.
    Yes I have seen this and have tried (successfully) adding routes this
    way. Works fine though I worry a bit about using the deprecated
    methods but couldn't find any alternative in the docs.
    You could also add routes dynamically at runtime [2] using Camel's JMX
    ManagedCamelContext MBean.
    This looks very interesting. Thanks. Perhaps this is the better way
    to avoid using deprecated methods. Though I am still left with my
    original question .. how to hook into a context lifecycle onStart()
    method so I can load up some preconfigured routes on startup. Using
    eithe 1 or 2 above. It looks like it should be easy but ...

    Regards
    Bob
  • Babak Vahdat at Apr 13, 2012 at 1:47 pm
    Aha, don't worry about those deprecated methods as they're all doubly
    declared both on:

    org.apache.camel.CamelContext

    And

    org.apache.camel.model.ModelCamelContext

    So just reference your context as ModelCamelContext, then you should be
    fine. At [1] you see a similar question. The corresponding JIRA Ticket is
    still open.

    [1]
    http://camel.465427.n5.nabble.com/What-replaces-camelContext-getRouteDefinition-String-routeId-td5530724.html

    Babak

    --
    View this message in context: http://camel.465427.n5.nabble.com/newbie-question-re-LifecycleManagementStrategy-tp5638024p5638343.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Claus Ibsen at Apr 13, 2012 at 3:13 pm
    Hi

    What runtime do you use? Tomcat, Standalone, OSGi etc?

    Camel should pickup that bean automatic as it lookup the registry by type.
    As shown here
    http://camel.apache.org/advanced-configuration-of-camelcontext-using-spring.html

    And does you class really have the correct name? It starts with import
    in the mail below.

    On Fri, Apr 13, 2012 at 1:25 PM, Bob Jolliffe wrote:
    Hi

    I am struggling a bit with loading a custom
    LifecycleManagementStrategy.  (Like some previous posters I am looking
    to load some xml routes on startup).

    I have created a class DHIS2LifecycleManagementStrategy which extends
    DefaultLifecycleManagementStrategy and overridden the onContextStart()
    method.  But I'm not sure what exactly to put in my spring beans
    configuration file in order for this strategy to be picked up.  I have
    the following:

    <!-- custom lifecycle strategy -->
    <bean id="lifecyclestrategy" class="import
    org.hisp.dhis.integration.management.DHIS2LifecycleManagementStrategy"
    />

    <camel:context .... />

    Any idea what I am missing?

    Thanks
    Bob


    --
    Claus Ibsen
    -----------------
    CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
    FuseSource
    Email: cibsen@fusesource.com
    Web: http://fusesource.com
    Twitter: davsclaus, fusenews
    Blog: http://davsclaus.blogspot.com/
    Author of Camel in Action: http://www.manning.com/ibsen/
  • Bob Jolliffe at Apr 14, 2012 at 9:36 pm
    Hi Claus
    On 13 April 2012 16:12, Claus Ibsen wrote:
    Hi

    What runtime do you use? Tomcat, Standalone, OSGi etc?
    Both tomcat and jetty in different settings.
    Camel should pickup that bean automatic as it lookup the registry by type.
    As shown here
    http://camel.apache.org/advanced-configuration-of-camelcontext-using-spring.html

    And does you class really have the correct name? It starts with import
    in the mail below.
    Yes that was a typo. It doesn't really have that name. But what I
    have found, which was surprizing but OK now that I know, is that the
    LifecycleStrategyManager does indeed work as expected (which is
    great), but it doesn't seem to be picked up during testing. I am
    guessing that the CamelTestSupport uses its own liefecycle manager.
    Is this true?
    On Fri, Apr 13, 2012 at 1:25 PM, Bob Jolliffe wrote:
    Hi

    I am struggling a bit with loading a custom
    LifecycleManagementStrategy.  (Like some previous posters I am looking
    to load some xml routes on startup).

    I have created a class DHIS2LifecycleManagementStrategy which extends
    DefaultLifecycleManagementStrategy and overridden the onContextStart()
    method.  But I'm not sure what exactly to put in my spring beans
    configuration file in order for this strategy to be picked up.  I have
    the following:

    <!-- custom lifecycle strategy -->
    <bean id="lifecyclestrategy" class="import
    org.hisp.dhis.integration.management.DHIS2LifecycleManagementStrategy"
    />

    <camel:context .... />

    Any idea what I am missing?

    Thanks
    Bob


    --
    Claus Ibsen
    -----------------
    CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
    FuseSource
    Email: cibsen@fusesource.com
    Web: http://fusesource.com
    Twitter: davsclaus, fusenews
    Blog: http://davsclaus.blogspot.com/
    Author of Camel in Action: http://www.manning.com/ibsen/
  • Claus Ibsen at Apr 15, 2012 at 7:57 am

    On Sat, Apr 14, 2012 at 11:35 PM, Bob Jolliffe wrote:
    Hi Claus
    On 13 April 2012 16:12, Claus Ibsen wrote:
    Hi

    What runtime do you use? Tomcat, Standalone, OSGi etc?
    Both tomcat and jetty in different settings.
    Camel should pickup that bean automatic as it lookup the registry by type.
    As shown here
    http://camel.apache.org/advanced-configuration-of-camelcontext-using-spring.html

    And does you class really have the correct name? It starts with import
    in the mail below.
    Yes that was a typo.  It doesn't really have that name.  But what I
    have found, which was surprizing but OK now that I know, is that the
    LifecycleStrategyManager does indeed work as expected (which is
    great), but it doesn't seem to be picked up during testing.  I am
    guessing that the CamelTestSupport uses its own liefecycle manager.
    Is this true?
    Are you using the CamelSpringTestSupport which support Spring?

    If you use pure Java for testing, you need to add the strategy using
    the Java API.
    There is API on CamelContext to do that.

    On Fri, Apr 13, 2012 at 1:25 PM, Bob Jolliffe wrote:
    Hi

    I am struggling a bit with loading a custom
    LifecycleManagementStrategy.  (Like some previous posters I am looking
    to load some xml routes on startup).

    I have created a class DHIS2LifecycleManagementStrategy which extends
    DefaultLifecycleManagementStrategy and overridden the onContextStart()
    method.  But I'm not sure what exactly to put in my spring beans
    configuration file in order for this strategy to be picked up.  I have
    the following:

    <!-- custom lifecycle strategy -->
    <bean id="lifecyclestrategy" class="import
    org.hisp.dhis.integration.management.DHIS2LifecycleManagementStrategy"
    />

    <camel:context .... />

    Any idea what I am missing?

    Thanks
    Bob


    --
    Claus Ibsen
    -----------------
    CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
    FuseSource
    Email: cibsen@fusesource.com
    Web: http://fusesource.com
    Twitter: davsclaus, fusenews
    Blog: http://davsclaus.blogspot.com/
    Author of Camel in Action: http://www.manning.com/ibsen/


    --
    Claus Ibsen
    -----------------
    CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
    FuseSource
    Email: cibsen@fusesource.com
    Web: http://fusesource.com
    Twitter: davsclaus, fusenews
    Blog: http://davsclaus.blogspot.com/
    Author of Camel in Action: http://www.manning.com/ibsen/
  • Bob Jolliffe at Apr 15, 2012 at 4:45 pm

    On 15 April 2012 08:56, Claus Ibsen wrote:
    On Sat, Apr 14, 2012 at 11:35 PM, Bob Jolliffe wrote:
    Hi Claus
    On 13 April 2012 16:12, Claus Ibsen wrote:
    Hi

    What runtime do you use? Tomcat, Standalone, OSGi etc?
    Both tomcat and jetty in different settings.
    Camel should pickup that bean automatic as it lookup the registry by type.
    As shown here
    http://camel.apache.org/advanced-configuration-of-camelcontext-using-spring.html

    And does you class really have the correct name? It starts with import
    in the mail below.
    Yes that was a typo.  It doesn't really have that name.  But what I
    have found, which was surprizing but OK now that I know, is that the
    LifecycleStrategyManager does indeed work as expected (which is
    great), but it doesn't seem to be picked up during testing.  I am
    guessing that the CamelTestSupport uses its own liefecycle manager.
    Is this true?
    Are  you using the CamelSpringTestSupport which support Spring?
    Changed from CamelTestSupport to CamelSpringTestSupport and all is
    well. Sorry for the questions which might seem very obvious. Your
    help is much appreciated in getting things moving.
    If you use pure Java for testing, you need to add the strategy using
    the Java API.
    There is API on CamelContext to do that.

    On Fri, Apr 13, 2012 at 1:25 PM, Bob Jolliffe wrote:
    Hi

    I am struggling a bit with loading a custom
    LifecycleManagementStrategy.  (Like some previous posters I am looking
    to load some xml routes on startup).

    I have created a class DHIS2LifecycleManagementStrategy which extends
    DefaultLifecycleManagementStrategy and overridden the onContextStart()
    method.  But I'm not sure what exactly to put in my spring beans
    configuration file in order for this strategy to be picked up.  I have
    the following:

    <!-- custom lifecycle strategy -->
    <bean id="lifecyclestrategy" class="import
    org.hisp.dhis.integration.management.DHIS2LifecycleManagementStrategy"
    />

    <camel:context .... />

    Any idea what I am missing?

    Thanks
    Bob


    --
    Claus Ibsen
    -----------------
    CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
    FuseSource
    Email: cibsen@fusesource.com
    Web: http://fusesource.com
    Twitter: davsclaus, fusenews
    Blog: http://davsclaus.blogspot.com/
    Author of Camel in Action: http://www.manning.com/ibsen/


    --
    Claus Ibsen
    -----------------
    CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
    FuseSource
    Email: cibsen@fusesource.com
    Web: http://fusesource.com
    Twitter: davsclaus, fusenews
    Blog: http://davsclaus.blogspot.com/
    Author of Camel in Action: http://www.manning.com/ibsen/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriescamel
postedApr 13, '12 at 11:25a
activeApr 15, '12 at 4:45p
posts8
users3
websitecamel.apache.org

People

Translate

site design / logo © 2022 Grokbase