Camel service start/stop

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

Camel service start/stop

kiranreddykasa
Hi i would like to know how to use the following class

http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/support/ServiceSupport.html

how can I make my custom class so that it is managed by camel ??
Regards

kiran Reddy
Reply | Threaded
Open this post in threaded view
|

Re: Camel service start/stop

ceposta
So that class implements the boiler plate code for lifecycle management
(start, stop, suspend, resume, isStarting, isStopping, etc).

If you want to have one of your custom classes managed by camel, you can
register it as a "service" by Implementing Service.java (or extending
ServiceSupport) and calling CamelContext#addService()...

You could also plug into the lifecycle by implementing
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/spi/LifecycleStrategy.htmland
registering with CamelContext#addLifecycleStrategy




On Tue, Aug 27, 2013 at 12:28 PM, kiranreddykasa <[hidden email]>wrote:

> Hi i would like to know how to use the following class
>
>
> http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/support/ServiceSupport.html
>
> how can I make my custom class so that it is managed by camel ??
>
>
>
> -----
> Regards
>
> kiran Reddy
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-service-start-stop-tp5738073.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta
Reply | Threaded
Open this post in threaded view
|

Re: Camel service start/stop

kiranreddykasa
Hi I have created a class by extending ServiceSupport.

And I'm staring my program with the following code.

  public static void main(String... args) throws Exception {
    AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext(
                                "classpath:/META-INF/spring/camel-context*.xml");
        Main main = new Main();
        main.setApplicationContext(applicationContext);
        main.enableHangupSupport();
        main.addRouteBuilder(new CustomeRouteBuilder());
        main.run(args);
       
    }

I'm not sure how to register service here.
Can I add it in applicationcontext file ?
Regards

kiran Reddy
Reply | Threaded
Open this post in threaded view
|

Re: Camel service start/stop

Claus Ibsen-2
In reply to this post by kiranreddykasa
Hi

See also
http://camel.apache.org/lifecycle

If your class is used in a route as part of a process or bean then
Camel will manage its lifecycle (eg calling start/stop etc). And
enlist in JMX also.

Though if your bean is used outside Camel you need to handle this
yourself, for example as Christian said you can use addService method
on CamelContext to add it to Camel and it will then also manage its
lifecycle when Camel starts/stops.

If you want your bean to be in JMX. Then spring has a jmx exporter you
can use for that also.


On Tue, Aug 27, 2013 at 9:28 PM, kiranreddykasa <[hidden email]> wrote:

> Hi i would like to know how to use the following class
>
> http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/support/ServiceSupport.html
>
> how can I make my custom class so that it is managed by camel ??
>
>
>
> -----
> Regards
>
> kiran Reddy
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-service-start-stop-tp5738073.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen