You have to have an Import-Service statement in the Manifest for the dependency to be recognized by the OSGi framework. I reference my services using blueprint and use the maven bundle plugin. So a suitable entry gets generated automatically. If you
use an Activator you will have to manually add the Manifest entry.

Christian

Am 25.04.2012 18:08, schrieb Jason:
Hi all,

Thanks for the quick feedback.

FWIW, the broker is registered as a service (javax.jms.ConnectionFactory).

My child projects get the ConnectionFactory from the BundleContext within the BundleActivator.start(BundleContext) method of my Activator and attach a MessageListener to a queue. I am using "features" and I set the child project's start-levels to 100. The start level of the broker is 80. The first time I start Karaf, everything starts up perfect....no exceptions. Then I shutdown the container, and start it up again. Upon startup for the second time, I get the following exceptions per child project:

(org.osgi.framework.BundleException: Activator start error in bundle xxxx 
[258].)
javax.jms.JMSException: Could not connect to broker URL: tcp://0.0.0.0:61616. 
Reason: java.net.ConnectException: Connection refused

When I get the prompt and type "start 258", it starts cleanly.

This suggests to me Achim's claim to not rely on start levels seems to have merit.

So, what is the best way to ensure that a parent service is started? Ought I check for the connectionexception and just loop until the broker starts up and I can get a valid connection?

Thanks,
Jason

On 04/25/2012 11:44 AM, Christian Schneider wrote:
Yes.

Referencing the connection factory that ActiveMQ publishes as an OSGi service is the best way to setup jms in Karaf anyway.

Christian

Am 25.04.2012 17:35, schrieb Guillaume Nodet:
No, but depending on the configuration it may expose a JMSCOnnectionFactory which can be obtained from the OSGi registry.

On Wed, Apr 25, 2012 at 17:30, Jean-Baptiste Onofré <[email protected] <mailto:[email protected]>> wrote:

    Agree Achim, however, I'm not sure that ActiveMQ register a
    service per queue or topic for instance (only for the broker).

    Regards
    JB


    On 04/25/2012 05:18 PM, Achim Nierbeck wrote:

        Never the less you shouldn't rely on the startlevels,
        I suggest that your application waits on services provided
        by the
        ActiveMQ broker.
        This is far more safe and more OSGi like ;)

        regards, Achim

        2012/4/25 Jean-Baptiste Onofré<[email protected]
        <mailto:[email protected]>>:

            Hi Jason,

            Using a feature, you can define the start-level of the
            bundles in the
            feature.

            Regards
            JB


            On 04/25/2012 05:12 PM, Jason wrote:


                Hi all,

                I have an application that uses Apache ActiveMQ in
                Karaf. I have a
                broker project and multiple other projects that
                should depend on the
                broker service to be started. How do I specify in
                the maven pom
                (maven-bundle-plugin) that the child projects should
                wait until the
                broker is started?

                Thanks,
                Jason



            --
            Jean-Baptiste Onofré
            [email protected] <mailto:[email protected]>
            http://blog.nanthrax.net
            Talend - http://www.talend.com





-- Jean-Baptiste Onofré
    [email protected] <mailto:[email protected]>
    http://blog.nanthrax.net
    Talend - http://www.talend.com




--
------------------------
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
FuseSource, Integration everywhere
http://fusesource.com


--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Divisionhttp://www.talend.com



--

Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com

Reply via email to