You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by smunro <st...@gmail.com> on 2017/12/08 13:13:32 UTC

ActiveMQ not starting soon enough

Hello,

I'm having a small issue where the ActiveMQ Service has not initialized in
time for a bundle I have developed. With our own bundles, we can resolve
ordering with declarative services, using @Reference, but I'm not sure how
to achieve the same with ActiveMQ. Basically, I want to make sure the
ActiveMQ bundle is actively up and running before any of my bundles, without
messing with start orders

Stephen



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: ActiveMQ not starting soon enough

Posted by smunro <st...@gmail.com>.
Hello Christian,

I have a bundle with uses both activemq-broker/activemq-client features

The Idea JB gave me, led me to try:
@Reference
public void setBrokerService(BrokerService brokerService}{}

My thinking here was that by the time this service reference was injected,
the activemq broker would be up and running.

To answer your question, the bundles simply throw connection exceptions. The
current solution I have is to entry a retry loop and catch and exception and
try to connect, but I know there is a failover setting in activemq would be
achieve roughly the same behaviour. 

The behaviour of the bundle is to try and first connect to the activemq
subscription bundle and get updates coming in.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: ActiveMQ not starting soon enough

Posted by Christian Schneider <ch...@die-schneider.net>.
Why cant your other bundles start without activemq?
What would happen if they do?

Christian

2017-12-08 14:13 GMT+01:00 smunro <st...@gmail.com>:

> Hello,
>
> I'm having a small issue where the ActiveMQ Service has not initialized in
> time for a bundle I have developed. With our own bundles, we can resolve
> ordering with declarative services, using @Reference, but I'm not sure how
> to achieve the same with ActiveMQ. Basically, I want to make sure the
> ActiveMQ bundle is actively up and running before any of my bundles,
> without
> messing with start orders
>
> Stephen
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>



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

Computer Scientist
http://www.adobe.com

Re: ActiveMQ not starting soon enough

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Stephen,

I see. Let me take a look in ActiveMQ to see why client also ship broker package 
(it sounds weird to me).

Regards
JB

On 12/09/2017 12:46 PM, smunro wrote:
> Thanks JB,
> 
> The second approach certainly feels the cleanest to me. I gave that a go and
> found it couldn't be achieved due to both the broker and client bundles
> exposing the same package:
>   <Import-Package>*,org.apache.activemq.broker</Import-Package>
> 
> So, sadly I can't get away with doing:
> @Reference
> public void setBrokerService(BrokerService brokerService){ .. }
> 
> This was raised on the activemq forums last April:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-and-OSGi-Two-bundles-export-the-same-package-org-apache-activemq-broker-td4730106.html
> 
> I'll try your first suggested approach, but I'm ma little disappointed I
> couldn't get the second method to work :(
> 
> Thanks again,
> Stephen
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: ActiveMQ not starting soon enough

Posted by smunro <st...@gmail.com>.
Thanks JB,

The second approach certainly feels the cleanest to me. I gave that a go and
found it couldn't be achieved due to both the broker and client bundles
exposing the same package: 
 <Import-Package>*,org.apache.activemq.broker</Import-Package>

So, sadly I can't get away with doing:
@Reference
public void setBrokerService(BrokerService brokerService){ .. }

This was raised on the activemq forums last April:
http://activemq.2283324.n4.nabble.com/ActiveMQ-and-OSGi-Two-bundles-export-the-same-package-org-apache-activemq-broker-td4730106.html

I'll try your first suggested approach, but I'm ma little disappointed I
couldn't get the second method to work :(

Thanks again,
Stephen



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: ActiveMQ not starting soon enough

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Stephen,

I would say, you have two approach:

- in the start method of your bundle, you can create a listener that check if 
the ActiveMQ transport connector (the tcp port for instance) is bound and then 
you move on.
- AFAIR, ActiveMQ OSGi exposes the BrokerService as an OSGi service. So, you can 
have a tracker on this one.

Regards
JB

On 12/08/2017 02:13 PM, smunro wrote:
> Hello,
> 
> I'm having a small issue where the ActiveMQ Service has not initialized in
> time for a bundle I have developed. With our own bundles, we can resolve
> ordering with declarative services, using @Reference, but I'm not sure how
> to achieve the same with ActiveMQ. Basically, I want to make sure the
> ActiveMQ bundle is actively up and running before any of my bundles, without
> messing with start orders
> 
> Stephen
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com