You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Zhemzhitsky Sergey <Se...@sberbank-cib.ru> on 2013/06/18 12:44:41 UTC

Camel Context InterceptStrategy

Hello guys,

I’d like to apply custom intercept strategy to a given camel context running in an OSGi environment at runtime.
I’ve implemented osgi service-reference listener (blueprint) that is notified when the camel context appears. When the listener is invoked the intercept strategy is added to the camel context.
Unfortunately, for the InterceptStrategy to be applied it’s necessary for the camel context to be restarted, but in OSGi environment stopping camel context means unregistering corresponding OSGi service and I’m not able to start is again.

So, is there any way to apply intercept strategy to the camel context without its restarting?

Best Regards,
Sergey Zhemzhitsky


_______________________________________________________
CONFIDENTIALITY NOTICE: This email and any files attached to it may be confidential. If you are not the intended recipient you are notified that using, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error please notify the sender and delete this email. 


RE: Camel Context InterceptStrategy

Posted by Zhemzhitsky Sergey <Se...@sberbank-cib.ru>.
Hi Clause,

Thanks for the notice!

Best Regards,
Sergey

-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Sent: Saturday, June 22, 2013 8:46 PM
To: users@camel.apache.org
Subject: Re: Camel Context InterceptStrategy

Hi

In Camel 2.12 you can use the Container SPI org.apache.camel.spi.Container



On Tue, Jun 18, 2013 at 12:44 PM, Zhemzhitsky Sergey <Se...@sberbank-cib.ru> wrote:
> Hello guys,
>
> I’d like to apply custom intercept strategy to a given camel context running in an OSGi environment at runtime.
> I’ve implemented osgi service-reference listener (blueprint) that is notified when the camel context appears. When the listener is invoked the intercept strategy is added to the camel context.
> Unfortunately, for the InterceptStrategy to be applied it’s necessary for the camel context to be restarted, but in OSGi environment stopping camel context means unregistering corresponding OSGi service and I’m not able to start is again.
>
> So, is there any way to apply intercept strategy to the camel context without its restarting?
>
> Best Regards,
> Sergey Zhemzhitsky
>
>
> _______________________________________________________
> CONFIDENTIALITY NOTICE: This email and any files attached to it may be confidential. If you are not the intended recipient you are notified that using, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error please notify the sender and delete this email.
>



--
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel Context InterceptStrategy

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

In Camel 2.12 you can use the Container SPI
org.apache.camel.spi.Container



On Tue, Jun 18, 2013 at 12:44 PM, Zhemzhitsky Sergey
<Se...@sberbank-cib.ru> wrote:
> Hello guys,
>
> I’d like to apply custom intercept strategy to a given camel context running in an OSGi environment at runtime.
> I’ve implemented osgi service-reference listener (blueprint) that is notified when the camel context appears. When the listener is invoked the intercept strategy is added to the camel context.
> Unfortunately, for the InterceptStrategy to be applied it’s necessary for the camel context to be restarted, but in OSGi environment stopping camel context means unregistering corresponding OSGi service and I’m not able to start is again.
>
> So, is there any way to apply intercept strategy to the camel context without its restarting?
>
> Best Regards,
> Sergey Zhemzhitsky
>
>
> _______________________________________________________
> CONFIDENTIALITY NOTICE: This email and any files attached to it may be confidential. If you are not the intended recipient you are notified that using, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error please notify the sender and delete this email.
>



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

RE: Camel Context InterceptStrategy

Posted by Zhemzhitsky Sergey <Se...@sberbank-cib.ru>.
Hello guys, 

Here is the source from camel 2.10 for the startRoute(RouteDefinition) and startRoute(String)

I suppose that the main difference between startRoute(RouteDefinition) and startRoute(String) (in camel 2.10) is 
route.prepare(this) + startRouteService(routeService, true) in the first method and startRouteService(routeService, false) in the second one.

So as the startRoute(RouteDefinition) is deprecated it seems that it will not be possible to apply the intercept strategies in the newer camel versions, although it works for now.

public void startRoute(RouteDefinition route) throws Exception {
    // indicate we are staring the route using this thread so
    // we are able to query this if needed
    isStartingRoutes.set(true);
    try {
        // must ensure route is prepared, before we can start it
        route.prepare(this);

        List<Route> routes = new ArrayList<Route>();
        List<RouteContext> routeContexts = route.addRoutes(this, routes);
        RouteService routeService = new RouteService(this, route, routeContexts, routes);
        startRouteService(routeService, true);
    } finally {
        // we are done staring routes
        isStartingRoutes.remove();
    }
}

public synchronized void startRoute(String routeId) throws Exception {
    RouteService routeService = routeServices.get(routeId);
    if (routeService != null) {
        startRouteService(routeService, false);
    }
}


Best Regards,
Sergey

-----Original Message-----
From: Christian Müller [mailto:christian.mueller@gmail.com] 
Sent: Wednesday, June 19, 2013 3:20 PM
To: users@camel.apache.org
Subject: Re: Camel Context InterceptStrategy

Sounds strange... But to be honest, It sounds like a question for Claus, Hadrian, ... ;-)

Best,

Christian Müller
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Wed, Jun 19, 2013 at 12:34 PM, Zhemzhitsky Sergey < Sergey_Zhemzhitsky@sberbank-cib.ru> wrote:

> Hi Christian,
>
> Thanks for the link, I've already studied it.
>
> I've managed to apply intercept strategies at runtime to a newly 
> registered CamelContext service with something like this
>
> camelCtx.addInterceptStrategy(interceptStrategy);
> for (RouteDefinition routeDef : camelCtx.getRouteDefinitions()) {
>     camelCtx.stopRoute(routeDef);
>     camelCtx.startRoute(routeDef);
> }
>
> The interesting thing is that CamelContext.startRoute(RouteDefinition)
> (which is deprecated now) applies the intercept strategies to the 
> underlying routes and CamelContext.startRoute(String) - does not.
> Is this an expected behavior or the JIRA issue should be raised?
>
>
> Best Regards,
> Sergey
>
> -----Original Message-----
> From: Christian Müller [mailto:christian.mueller@gmail.com]
> Sent: Wednesday, June 19, 2013 2:29 AM
> To: users@camel.apache.org
> Subject: Re: Camel Context InterceptStrategy
>
> I guess you already studied http://camel.apache.org/intercept.html
>
> Best,
> Christian
>
> Sent from a mobile device
> Am 18.06.2013 12:45 schrieb "Zhemzhitsky Sergey" <
> Sergey_Zhemzhitsky@sberbank-cib.ru>:
>
> > Hello guys,
> >
> > I’d like to apply custom intercept strategy to a given camel context 
> > running in an OSGi environment at runtime.
> > I’ve implemented osgi service-reference listener (blueprint) that is 
> > notified when the camel context appears. When the listener is 
> > invoked the intercept strategy is added to the camel context.
> > Unfortunately, for the InterceptStrategy to be applied it’s 
> > necessary for the camel context to be restarted, but in OSGi 
> > environment stopping camel context means unregistering corresponding 
> > OSGi service and I’m not able to start is again.
> >
> > So, is there any way to apply intercept strategy to the camel 
> > context without its restarting?
> >
> > Best Regards,
> > Sergey Zhemzhitsky
> >
> >
> > _______________________________________________________
> > CONFIDENTIALITY NOTICE: This email and any files attached to it may 
> > be confidential. If you are not the intended recipient you are 
> > notified that using, copying, distributing or taking any action in 
> > reliance on the contents of this information is strictly prohibited. 
> > If you have received this email in error please notify the sender 
> > and delete this
> email.
> >
> >
>

Re: Camel Context InterceptStrategy

Posted by Christian Müller <ch...@gmail.com>.
Sounds strange... But to be honest, It sounds like a question for Claus,
Hadrian, ... ;-)

Best,

Christian Müller
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Wed, Jun 19, 2013 at 12:34 PM, Zhemzhitsky Sergey <
Sergey_Zhemzhitsky@sberbank-cib.ru> wrote:

> Hi Christian,
>
> Thanks for the link, I've already studied it.
>
> I've managed to apply intercept strategies at runtime to a newly
> registered CamelContext service with something like this
>
> camelCtx.addInterceptStrategy(interceptStrategy);
> for (RouteDefinition routeDef : camelCtx.getRouteDefinitions()) {
>     camelCtx.stopRoute(routeDef);
>     camelCtx.startRoute(routeDef);
> }
>
> The interesting thing is that CamelContext.startRoute(RouteDefinition)
> (which is deprecated now) applies the intercept strategies to the
> underlying routes and CamelContext.startRoute(String) - does not.
> Is this an expected behavior or the JIRA issue should be raised?
>
>
> Best Regards,
> Sergey
>
> -----Original Message-----
> From: Christian Müller [mailto:christian.mueller@gmail.com]
> Sent: Wednesday, June 19, 2013 2:29 AM
> To: users@camel.apache.org
> Subject: Re: Camel Context InterceptStrategy
>
> I guess you already studied http://camel.apache.org/intercept.html
>
> Best,
> Christian
>
> Sent from a mobile device
> Am 18.06.2013 12:45 schrieb "Zhemzhitsky Sergey" <
> Sergey_Zhemzhitsky@sberbank-cib.ru>:
>
> > Hello guys,
> >
> > I’d like to apply custom intercept strategy to a given camel context
> > running in an OSGi environment at runtime.
> > I’ve implemented osgi service-reference listener (blueprint) that is
> > notified when the camel context appears. When the listener is invoked
> > the intercept strategy is added to the camel context.
> > Unfortunately, for the InterceptStrategy to be applied it’s necessary
> > for the camel context to be restarted, but in OSGi environment
> > stopping camel context means unregistering corresponding OSGi service
> > and I’m not able to start is again.
> >
> > So, is there any way to apply intercept strategy to the camel context
> > without its restarting?
> >
> > Best Regards,
> > Sergey Zhemzhitsky
> >
> >
> > _______________________________________________________
> > CONFIDENTIALITY NOTICE: This email and any files attached to it may be
> > confidential. If you are not the intended recipient you are notified
> > that using, copying, distributing or taking any action in reliance on
> > the contents of this information is strictly prohibited. If you have
> > received this email in error please notify the sender and delete this
> email.
> >
> >
>

RE: Camel Context InterceptStrategy

Posted by Zhemzhitsky Sergey <Se...@sberbank-cib.ru>.
Hi Christian,

Thanks for the link, I've already studied it. 

I've managed to apply intercept strategies at runtime to a newly registered CamelContext service with something like this

camelCtx.addInterceptStrategy(interceptStrategy);
for (RouteDefinition routeDef : camelCtx.getRouteDefinitions()) {
    camelCtx.stopRoute(routeDef);
    camelCtx.startRoute(routeDef);
}

The interesting thing is that CamelContext.startRoute(RouteDefinition) (which is deprecated now) applies the intercept strategies to the underlying routes and CamelContext.startRoute(String) - does not.
Is this an expected behavior or the JIRA issue should be raised?
 

Best Regards,
Sergey 

-----Original Message-----
From: Christian Müller [mailto:christian.mueller@gmail.com] 
Sent: Wednesday, June 19, 2013 2:29 AM
To: users@camel.apache.org
Subject: Re: Camel Context InterceptStrategy

I guess you already studied http://camel.apache.org/intercept.html

Best,
Christian

Sent from a mobile device
Am 18.06.2013 12:45 schrieb "Zhemzhitsky Sergey" <
Sergey_Zhemzhitsky@sberbank-cib.ru>:

> Hello guys,
>
> I’d like to apply custom intercept strategy to a given camel context 
> running in an OSGi environment at runtime.
> I’ve implemented osgi service-reference listener (blueprint) that is 
> notified when the camel context appears. When the listener is invoked 
> the intercept strategy is added to the camel context.
> Unfortunately, for the InterceptStrategy to be applied it’s necessary 
> for the camel context to be restarted, but in OSGi environment 
> stopping camel context means unregistering corresponding OSGi service 
> and I’m not able to start is again.
>
> So, is there any way to apply intercept strategy to the camel context 
> without its restarting?
>
> Best Regards,
> Sergey Zhemzhitsky
>
>
> _______________________________________________________
> CONFIDENTIALITY NOTICE: This email and any files attached to it may be 
> confidential. If you are not the intended recipient you are notified 
> that using, copying, distributing or taking any action in reliance on 
> the contents of this information is strictly prohibited. If you have 
> received this email in error please notify the sender and delete this email.
>
>

Re: Camel Context InterceptStrategy

Posted by Christian Müller <ch...@gmail.com>.
I guess you already studied http://camel.apache.org/intercept.html

Best,
Christian

Sent from a mobile device
Am 18.06.2013 12:45 schrieb "Zhemzhitsky Sergey" <
Sergey_Zhemzhitsky@sberbank-cib.ru>:

> Hello guys,
>
> I’d like to apply custom intercept strategy to a given camel context
> running in an OSGi environment at runtime.
> I’ve implemented osgi service-reference listener (blueprint) that is
> notified when the camel context appears. When the listener is invoked the
> intercept strategy is added to the camel context.
> Unfortunately, for the InterceptStrategy to be applied it’s necessary for
> the camel context to be restarted, but in OSGi environment stopping camel
> context means unregistering corresponding OSGi service and I’m not able to
> start is again.
>
> So, is there any way to apply intercept strategy to the camel context
> without its restarting?
>
> Best Regards,
> Sergey Zhemzhitsky
>
>
> _______________________________________________________
> CONFIDENTIALITY NOTICE: This email and any files attached to it may be
> confidential. If you are not the intended recipient you are notified that
> using, copying, distributing or taking any action in reliance on the
> contents of this information is strictly prohibited. If you have received
> this email in error please notify the sender and delete this email.
>
>