Sujit Biswas
- All
- Personal
- REST-style
- Sun
Jms Messaging Bridge
What is a jms Bridge?
A messaging bridge consists of two destinations that are being bridged: a Source destination that the bridge reads messages from and a Target destination where the bridge sends the messages that it receives from the source destination. Many of the jms provider provide the jms bridge capabilty. However it is also easy to build a custom JMSbridge using JMSJCA

Building jms bridge using java or Composite Application
1. Using standalone java application
JMSJCA support connecting to various JMS Providers like Sun Java Message Queue, JBossMQ, Websphere Message Queue or MQSeries, Weblogic JMS Server, JMS Grid, STCMS. So if one want to build bridge which does not require support for XA transaction. One can easily use the JMSJCA as library for the purpose as it provide a unified interface for accessing the JMS Providers. The diagram below shows the flow of message.

2. Using javaee container
However one may like to make the bridge more reliable. and like to treat the receiving of messages from the source and delivering the same to the target as atomic, i.e want the bridge to support XA transaction, then it will ideal to use javaee container for that purpose, We will show a sample piece of pseudo code which use MDB to build a bridge.
More Info on How to create a MDB and jms Message Producer using JMSJCA in glassfish is available here
Lets say that the requirement is to build a bridge for Sun-Java-Message-Queue to Websphere-Message-Queue , One can use the following logic in the MDB
public void onMessage(Message sunJavaMessage){
//sunJavaMessage is the received message from Sun Java MQ ,
- Create a producer, for say Websphere Message Queue(WMQ)
- Transform message Header, Properties, Body from SunJava-MQ to WMQ message
- Send the message
}
Note that the step 2 , is the crucial step which one need to implement. While implementing the Message Conventer one has to take care of the following
- iterate over jms Message Properties, copy from source to destination
- handle vender specific properties, i.e properties starting with JMS_
- copy message Body, note Text, Map, Byte,Object, Stream Message needs to handled seperately
- copy relevant jms headers (like jms type, correlationId, timestamp, priority, expiration etc)
Some of the advantages of using a javaee container along with JMSJCA are
- The ejb(mdb) container takes care of the reliable delivery
- One can have a scalable messaging bridge
- Resource Management, Connection pooling , MDB Instance pooling is done by the container
- In case of a crash, the appServer/ejb container takes care of recovery
- leverage the JMSJCA monitoring capabilty
- redelivery handling
- JMSJCA message wrapping
3. Building jms bridge using Composite Application
Idea is, Can we build a jms messaging bridge without any java-code , One can create a composite application which uses jmsbc-->bpel-->jmsbc . Note One limitation of building a bridge using jmsbc is that not all the jms message type is supported by jmsbc, Only supported Message are TextMessage, BytesMessage and MapMessage. Also if one require to convert all the message Header , Properties from source to destination , then one has to create a more involved wsdl. More info on creating composite applications using JMSBC and BPEL. The diagram below shows the flow of message.

step a) Create a CompositeApp using jmsbc-->bpel-->jmsbc
step b) Use the bpel mapper to map message properties , header and body
Use the bpel mapper to copy the message headers, properties and body, Note this takes care of only part of the message conversation, However one can always specify the message parts which maps to other message properties, see the link for more info

More info on Messaging Bridge and their JMS provider
- Weblogic Messaging Bridge
- Sun Java Message Queue
- Jboss Messaging Bridge
- ActiveMQ bridge
- SoniqMQ Bridge
Posted at 03:42PM Apr 29, 2009 by sujit in Sun | Comments[2]
Google Data API, Restify your app
The example above shows a google calender using google Calender Data API, Idea is that building app has now become much easier with the advent of REST-style APIs , it is very easy to plugin google map, or google calender etc, using the google data API
More info on the google data API , Rest-style API
Posted at 04:37PM Apr 09, 2009 by sujit in REST-style | Comments[0]