ActiveMQ & OSGI dependency

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ActiveMQ & OSGI dependency

smunro
Hello,

 I have an OSGI bundle which makes use of the ActiveMQ OSGI feature. The
problem is that my bundle starts too early and there is no connection to the
broker available.

I don't want to mess around with start levels in karaf as it's not
guaranteed to work. The only other option I can think of is to define a loop
that repeatedly tries to connect, but I was hoping there might be a cleaner
option. It would be nice if I could get a handle to the broker and block my
own bundle until it's up a new running (without looping and catching
connection exceptions). Any suggestions?



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ & OSGI dependency

seijoed
Use a failover connector URI?
It’ll keep trying to reconnect until a connection is established.
You can control retry-time and so on.

/je

> On Dec 8, 2017, at 4:24 PM, smunro <[hidden email]> wrote:
>
> Hello,
>
> I have an OSGI bundle which makes use of the ActiveMQ OSGI feature. The
> problem is that my bundle starts too early and there is no connection to the
> broker available.
>
> I don't want to mess around with start levels in karaf as it's not
> guaranteed to work. The only other option I can think of is to define a loop
> that repeatedly tries to connect, but I was hoping there might be a cleaner
> option. It would be nice if I could get a handle to the broker and block my
> own bundle until it's up a new running (without looping and catching
> connection exceptions). Any suggestions?
>
>
>
> --
> Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ & OSGI dependency

smunro
This post was updated on .
Hello seijoed,

Thanks for the reply.

That sounds like the way to go given the options I've looked at. I did find
something earlier that looked very promising, the BrokerService, which I
tried to use as follows

@Reference
public void setBrokerService(BrokerService service){..}

The problem with this is that I use both the client/server features and the
org.apache.activemq.broker package is split across bundles, which causes the
OSGI container problems. I'm not sure if the BrokerService would have given
me exactly what I needed, but my thinking was that the bundle would not have
started up until the BrokerService was available to service requests. Sadly,
that route doesn't appear to be open, and your suggestion seems to be the
best way to proceed.

Thanks again,
Stephen



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html