You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kiranreddykasa <ki...@fss.co.in> on 2013/08/27 21:28:05 UTC

Camel service start/stop

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.

Re: Camel service start/stop

Posted by kiranreddykasa <ki...@fss.co.in>.
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
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-service-start-stop-tp5738073p5738109.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel service start/stop

Posted by Christian Posta <ch...@gmail.com>.
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 <ki...@fss.co.in>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

Re: Camel service start/stop

Posted by Claus Ibsen <cl...@gmail.com>.
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 <ki...@fss.co.in> 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: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen