ROSE Event-Bridge

Work in Progress

1 The JMS Event Bridge

A simple bridge to do a mapping between the OSGi event (with the Event Admin) & the JMS event.

How to use it ?

The first thing to do, is to initialize the JMS connection properties. Then you can simply import a JMS topic on the event admin or export an OSGi topic with JMS.

How to initialize the JMS Connection properties

To initialize the JMS Event Bridge you have to fill some optional JMS connection properties at the creation of the instance of the JMSEventBridge. The properties are:

  • user : Your login on your Server.
  • pass : Your password on your Server.
So an example of configuration is:
<instance component="org.ow2.chameleon.rose.jms.eventbridge.impl.JmsEventManager" name="OW2 Chameleon ROSE JMS Event Bridge">
	<property name="user" value="root"/>
    	<property name="pass" value="root"/>
</instance>

How to export an OSGi topic with the RoseEventBridge service ?

To do this, just call the method: JmsEventBridge.addExportTopic('the OSGi topic name'). The call returns an object, this is the key to stop exporting the topic. In order to do that just call the method: JmsEventBridge.removeExportTopic('key'). If you prefer to specify your own mapping, call the method JmsEventBridge.addExportTopic>('the osgi topic name','the JMS topic name'). In this way, the OSGi event from the osgi topic 'the osgi topic name' will be mapped on the JMS topic 'the JMS topic name'.

RoseEventBridge m_jmseventbridge;
 Object topic_key;

public void export(topictoexport){ try { topic_key = m_jmseventbridge.addExportTopic(topictoexport); } catch (RoseEventBridgeException e) { //handle exception } }

public void unexport(key){ try { m_jmseventbridge.removeExportTopic(key); } catch (RoseEventBridgeException e) { //handle exception } }

How to import an JMS topic with the JmsEventBridge service ?

To do this, just call the method: JmsEventBridge.addImportTopic('the JMS topic name'). The call returns an object, this is the key to stop exporting the topic. In order to do that just call the method: JmsEventBridge.removeImportTopic('key'). The imported topic is automatically map to the EventAdmin. For example, the jms topic: 'event$bridge$osgi' will be map to the osgi topic: 'event/bridge/osgi'. If you prefer to specify your own mapping, call the method JmsEventBridge.addImportTopic('the JMS topic name','the osgi topic name'). In this way, the JMS message from the jms topic 'the JMS topic name' will be mapped on the osgi topic 'the osgi topic name'.

RoseEventBridge m_jmseventbridge;
 Object topic_key;

public void import(topictoimport){ try { topic_key = m_jmseventbridge.addImportTopic(topictoimport); } catch (RoseEventBridgeException e) { //handle exception } }

public void unimport(key){ try { m_jmseventbridge.removeImportTopic(key); } catch (RoseEventBridgeException e) { //handle exception } }

About the key ?

The key is an REBKey object. This key define the following methods:

  • REBKey.getOSGiTopicName(): The name of the OSGi topic which refers to this key
  • REBKey.getRoseTopicName(): The name of the JMS topic which refers to this key
  • REBKey.isAnImport(): To know if this key refers to an import
  • REBKey.isAnExport(): To know if this key refers to an export
  • REBKey.getId(): Return the id of this Key

How to list the exported topics ?

You can list the exported topics with the method: RoseEventBridge.getExportedTopics(). It returns a Collection of the exported topics.

How to list the imported topics ?

In the same way, you can list the imported topics by calling the method: RoseEventBridge.getImportedTopics(). It returns a Collection of the imported topics.

About the default mapping

The default mapping is quite simple. You have to notice that the separators used for the topic name are '/' for OSGi and '$' for JMS. The OSGi topic: 'osgi/topic/sample' will be mapped to the JMS topic: 'osgi$topic$sample'. On the other hand the imported JMS topic 'osgi$topic$sample' will be mapped to the OSGi topic 'osgi/topic/sample'. Take care not to import one of your exported topics. However, in that case, you will receive a RoseEventBridgeException to avoid the loop.