You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Zach Calvert <za...@gmail.com> on 2013/10/30 22:09:45 UTC

Solving Race Condition for Components

Hello,
I'm making use of the cxfbean component in Apache ServiceMix 4.5.3.  I have
reviewed the source and OSGI services being exposed here to try to get
around the race condition I am experiencing, but while the service is up
and running, ServiceMix/Camel does not yet recognize the component and I'm
not sure who to direct this question/problem to.

Breakdown:
I have a bundle which has the following route:

        <camel:route>
            <camel:from uri="jetty:
http://0.0.0.0:9089/health/?matchOnUriPrefix=true" />
            <camel:to uri="cxfbean:healthService" />
        </camel:route>

The health service implementation is a standard javax.ws.rs annotated
class.  The cxfbean is exposed in the camel-cxf feature under
the camel-cxf-2.10.7 bundle (I have confirmed).  To try to enforce that the
cxfbean service really, really is running, I have added
<osgi:reference id="cxfbeanReference" cardinality="1..1"
interface="org.apache.camel.spi.ComponentResolver"
filter="(component=cxfbean)" />
to my bundle.  This osgi reference is met and fully populated, however I
still get
"----
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
route route1 at: >>> To[cxfbean:healthService] <<< in route:
Route[[From[jetty:http://0.0.0.0:9089... because of Failed to resolve
endpoint: cxfbean://healthService due to: No component found with scheme:
cxfbean
---"
in my ServiceMix startup.  Note that this bundle is deployed in the
apache-servicemix-4.5.3/deploy directory on a Linux machine.

This issue can be resolved simply by waiting for ServiceMix to be started
for a few minutes and then run
 touch
./apache-servicemix-4.5.3/deploy/ecs.bundles.health-2.3.0.25-SNAPSHOT.jar

I would like to have the bundle block until the "cxfbean" component is
fully started.  Again this is a race condition and functionality is fully
restored by waiting a couple of minutes and then running touch on the
bundle that exposes this camel route.

Re: Solving Race Condition for Components

Posted by Zach Calvert <za...@gmail.com>.
We are using Spring.  I looked up the blueprint dependency chaining method
(which I am unfamiliar with) of
<capabilities>
                <capability name="org.apache.cxf" startlevel="3"/>
            </capabilities>

Is there a similar mechanism to require capabilities for my camel route?

Thanks for your help Gert!
Zach Calvert



On Mon, Nov 4, 2013 at 7:15 AM, Gert Vanthienen
<ge...@gmail.com>wrote:

> Zach,
>
>
> I think the Blueprint namespace handler should actually be able to
> wait for components to be added to the OSGi Service Registry.  Are you
> using Blueprint or Spring to define the Camel routes?
>
>
> Regards,
>
> Gert Vanthienen
>
>
> On Wed, Oct 30, 2013 at 10:09 PM, Zach Calvert <za...@gmail.com>
> wrote:
> > Hello,
> > I'm making use of the cxfbean component in Apache ServiceMix 4.5.3.  I
> have
> > reviewed the source and OSGI services being exposed here to try to get
> > around the race condition I am experiencing, but while the service is up
> > and running, ServiceMix/Camel does not yet recognize the component and
> I'm
> > not sure who to direct this question/problem to.
> >
> > Breakdown:
> > I have a bundle which has the following route:
> >
> >         <camel:route>
> >             <camel:from uri="jetty:
> > http://0.0.0.0:9089/health/?matchOnUriPrefix=true" />
> >             <camel:to uri="cxfbean:healthService" />
> >         </camel:route>
> >
> > The health service implementation is a standard javax.ws.rs annotated
> > class.  The cxfbean is exposed in the camel-cxf feature under
> > the camel-cxf-2.10.7 bundle (I have confirmed).  To try to enforce that
> the
> > cxfbean service really, really is running, I have added
> > <osgi:reference id="cxfbeanReference" cardinality="1..1"
> > interface="org.apache.camel.spi.ComponentResolver"
> > filter="(component=cxfbean)" />
> > to my bundle.  This osgi reference is met and fully populated, however I
> > still get
> > "----
> > Caused by: org.apache.camel.FailedToCreateRouteException: Failed to
> create
> > route route1 at: >>> To[cxfbean:healthService] <<< in route:
> > Route[[From[jetty:http://0.0.0.0:9089... because of Failed to resolve
> > endpoint: cxfbean://healthService due to: No component found with scheme:
> > cxfbean
> > ---"
> > in my ServiceMix startup.  Note that this bundle is deployed in the
> > apache-servicemix-4.5.3/deploy directory on a Linux machine.
> >
> > This issue can be resolved simply by waiting for ServiceMix to be started
> > for a few minutes and then run
> >  touch
> > ./apache-servicemix-4.5.3/deploy/ecs.bundles.health-2.3.0.25-SNAPSHOT.jar
> >
> > I would like to have the bundle block until the "cxfbean" component is
> > fully started.  Again this is a race condition and functionality is fully
> > restored by waiting a couple of minutes and then running touch on the
> > bundle that exposes this camel route.
>

Re: Solving Race Condition for Components

Posted by Gert Vanthienen <ge...@gmail.com>.
Zach,


I think the Blueprint namespace handler should actually be able to
wait for components to be added to the OSGi Service Registry.  Are you
using Blueprint or Spring to define the Camel routes?


Regards,

Gert Vanthienen


On Wed, Oct 30, 2013 at 10:09 PM, Zach Calvert <za...@gmail.com> wrote:
> Hello,
> I'm making use of the cxfbean component in Apache ServiceMix 4.5.3.  I have
> reviewed the source and OSGI services being exposed here to try to get
> around the race condition I am experiencing, but while the service is up
> and running, ServiceMix/Camel does not yet recognize the component and I'm
> not sure who to direct this question/problem to.
>
> Breakdown:
> I have a bundle which has the following route:
>
>         <camel:route>
>             <camel:from uri="jetty:
> http://0.0.0.0:9089/health/?matchOnUriPrefix=true" />
>             <camel:to uri="cxfbean:healthService" />
>         </camel:route>
>
> The health service implementation is a standard javax.ws.rs annotated
> class.  The cxfbean is exposed in the camel-cxf feature under
> the camel-cxf-2.10.7 bundle (I have confirmed).  To try to enforce that the
> cxfbean service really, really is running, I have added
> <osgi:reference id="cxfbeanReference" cardinality="1..1"
> interface="org.apache.camel.spi.ComponentResolver"
> filter="(component=cxfbean)" />
> to my bundle.  This osgi reference is met and fully populated, however I
> still get
> "----
> Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
> route route1 at: >>> To[cxfbean:healthService] <<< in route:
> Route[[From[jetty:http://0.0.0.0:9089... because of Failed to resolve
> endpoint: cxfbean://healthService due to: No component found with scheme:
> cxfbean
> ---"
> in my ServiceMix startup.  Note that this bundle is deployed in the
> apache-servicemix-4.5.3/deploy directory on a Linux machine.
>
> This issue can be resolved simply by waiting for ServiceMix to be started
> for a few minutes and then run
>  touch
> ./apache-servicemix-4.5.3/deploy/ecs.bundles.health-2.3.0.25-SNAPSHOT.jar
>
> I would like to have the bundle block until the "cxfbean" component is
> fully started.  Again this is a race condition and functionality is fully
> restored by waiting a couple of minutes and then running touch on the
> bundle that exposes this camel route.