Search code examples
jmsosgiactivemq-classiceclipse-ecf

How to use ECF JMS/ActiveMQ provider with remote services?


In order to make an OSGI service to be remotely accessible, I'd like to use ActiveMQ JMS broker as a distribution provider inside ECF framework. Which steps should I take?


Solution

  • I'll be answering my own question in order to document it.

    1. Get a minimal working ECF remote service workspace, with ecf.generic.server as the distribution and one of the discovery providers (zookeeper for example). You can use http://wiki.eclipse.org/EIG:Getting_Started_with_OSGi_Remote_Services tutorial.

    2. Install an ActiveMQ broker with default configuration.

    3. Download the JMS/ActiveMQ ECF providers from https://github.com/ECF/JMS. Add the org.eclipse.ecf.provider.jms and org.eclipse.ecf.provider.jms.activemq projects in your workspace, build and add them to your run configuration or target platform.

    4. For the provider service properties, do the following changes:

      a. Change the "service.exported.configs" property for as "ecf.jms.activemq.tcp.client"

      b. Add "ecf.endpoint.connecttarget.id" property with the following value "tcp://[ACTIVEMQ_IP]:61616/rs_topic", replacing [ACTIVEMQ_IP] with the broker IP. You can also change the topic name as something related to your service.

    5. Now we also need a ActiveMQ JMS Server Container. Add the following code to the provider side. Use the Activator or fire up a new component with DS. You can also get an IContainerFactory object from the service registry.

      IContainerFactory containerFactory = ContainerFactory.getDefault();
      containerFactory.createContainer("ecf.jms.activemq.tcp.manager", 
      new Object[] { "tcp://[ACTIVEMQ_IP]:61616/rs_topic" });