I had a client with a similar requirement a while back, and what I wound up doing was writing a couple of simple bundles that dynamically registered OSGi services. I need two - on for running in the same JVM as the ActiveMQ broker and another for running in a different JVM.
The bundle that ran in the same JVM watched for a JMX MBean to show up for the broker before it registered it’s service, while the bundle that ran in a separate JVM tried to connect to the broker and would registered the service once a connection could be made. In both cases, the services were unregistered if the broker was unavailable.
Unfortunately I don’t have that code to share anymore.
> On Dec 9, 2017, at 3:53 AM, smunro <[hidden email]> wrote:
> I've got a small project which has an OSGI bundle deployed on Karaf. It uses
> the latest ActiveMQ feature. The issue is that my bundle is starting up
> before the Broker has fully started.
> Is there a clean way to tell the bundle to wait until the broker has fully
> initialised to start receiving connections. I don't want to rely on start
> levels as they are not reliable. I've also tried basic things like a loop
> that catches exceptions until it finally connects, but that doesn't feel
> very clean and I thought I'd ask if there is a better way to handle this?
> All I want is for my bundle to wait until ActiveMQ is up and running. is
> there a better way to handle this that what I've already suggested?
> Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html