You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Giuseppe Gerla <gi...@gmail.com> on 2019/02/19 09:44:55 UTC
Karaf - AMQ Borker startup
Hi guys
I have a problem with amq broker. My bundle try to connect to the broker,
beofre it is started.
How can I check programatically that the broker is started?
There is an OSGi service for the broker, so I can use a tracker?
Thanks
regards
Giuseppe
Re: Karaf - AMQ Borker startup
Posted by ggerla <gi...@gmail.com>.
Ok, thanks
I created a thread that is started from the activator.
This thread check the connection to the broker and ends when the connection
is ok.
I don't like very much this solution, but it works for now.
What do you think to add a service registration after the broker is started?
I mean in the activemq-osgi project, change the ActiveMQServiceFactory
class, adding at row 146 following code:
bundleContext.registerService(BrokerService.class.getName(), broker,
filter);
where filter contains at least the broker name.
--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: Karaf - AMQ Borker startup
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
It's not exactly what you want I guess, but pretty close:
https://github.com/apache/karaf/blob/master/itests/test/src/test/java/org/apache/karaf/itests/JmsTest.java
Basically, you can try to open a ServerSocket on the transport connector
port to check if it's bound or not. You can do that in the activator of
your bundle for instance.
Regards
JB
On 19/02/2019 18:13, ggerla wrote:
> Ok JB
> can you give me the name of the test inside karaf itest to check what I have
> to do?
>
>
>
> --
> 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: Karaf - AMQ Borker startup
Posted by ggerla <gi...@gmail.com>.
Ok JB
can you give me the name of the test inside karaf itest to check what I have
to do?
--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: Karaf - AMQ Borker startup
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,
I think the most reliable is to check the transport connector then.
Regards
JB
On 19/02/2019 16:14, ggerla wrote:
> jbonofre wrote
>> The broker itself is not registered as an OSGi service (I can do the
>> improvement).
>
> This would be nice. I think that this is the best way to be sure that the
> broker is started.
>
>
> jbonofre wrote
>> You should check the blueprint container service associated with the
>> broker.
>
> This is not clear for me... can you explain better?
>
>
> jbonofre wrote
>> Another option is to use a ConfigListener on org.apache.activemq.server
>> factory.
>
> I think that I cannot use this solution because the factory is registered
> before the broker is started.
>
>
>
> Thanks
> Giuseppe
>
>
>
>
> --
> 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: Karaf - AMQ Borker startup
Posted by ggerla <gi...@gmail.com>.
jbonofre wrote
> The broker itself is not registered as an OSGi service (I can do the
> improvement).
This would be nice. I think that this is the best way to be sure that the
broker is started.
jbonofre wrote
> You should check the blueprint container service associated with the
> broker.
This is not clear for me... can you explain better?
jbonofre wrote
> Another option is to use a ConfigListener on org.apache.activemq.server
> factory.
I think that I cannot use this solution because the factory is registered
before the broker is started.
Thanks
Giuseppe
--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: Karaf - AMQ Borker startup
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
The broker itself is not registered as an OSGi service (I can do the
improvement).
You should check the blueprint container service associated with the broker.
Another option is to use a ConfigListener on org.apache.activemq.server
factory.
Regards
JB
On 19/02/2019 14:32, ggerla wrote:
> Hi JB
> I think that the right solution is to use ServiceTracker.
> The problem is that I didn't find which is the service name/interface to
> track.
> In the ActiveMQServiceFactory there are no service registrations....
>
>
>
>
> Thanks
> Giuseppe
>
>
>
>
> --
> 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: Karaf - AMQ Borker startup
Posted by ggerla <gi...@gmail.com>.
Hi JB
I think that the right solution is to use ServiceTracker.
The problem is that I didn't find which is the service name/interface to
track.
In the ActiveMQServiceFactory there are no service registrations....
Thanks
Giuseppe
--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: Karaf - AMQ Borker startup
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Giuseppe,
let me find some snippets (or do it ;)) for you.
Regards
JB
On 19/02/2019 12:22, ggerla wrote:
> Hi JB
> Cool. I'm interested to first 2 solutions.
>
> Can you give me more details or URL to guide pages where I can find more
> information?
>
>
> Thanks
> Regards
> Giuseppe
>
>
>
>
> --
> 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: Karaf - AMQ Borker startup
Posted by ggerla <gi...@gmail.com>.
Hi JB
Cool. I'm interested to first 2 solutions.
Can you give me more details or URL to guide pages where I can find more
information?
Thanks
Regards
Giuseppe
--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: Karaf - AMQ Borker startup
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Giuseppe,
there's different ways:
1. You can use feature and define the broker feature as
prerequisite=true. Then the broker feature will be installed before others.
2. You can use a ServiceTracker to listen for the broker service.
3. You can also test if the transport connector is bound (it's what we
are using in the Karaf itest for instance).
4. You can play with the start level.
Regards
JB
On 19/02/2019 10:44, Giuseppe Gerla wrote:
> Hi guys
> I have a problem with amq broker. My bundle try to connect to the
> broker, beofre it is started.
> How can I check programatically that the broker is started?
> There is an OSGi service for the broker, so I can use a tracker?
>
>
>
> Thanks
> regards
> Giuseppe
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com