Friday, 5 April 2013

OSB - OpenJMS Integration

I have been searching for tutorials about sending message to JMS from OSB business service. Most of the examples are integration between OSB and Weblogic JMS provider. So I wanted to figure out how to configure a different JMS provider in my example OpenJMS.

Our Business service will be a simple message producer. And we will use a sample Java class as a consumer.

Start the OpenJMS provider by running the <OpenJMS_Home>/bin/startup.bat. 

By default the OpenJMS has 2 JNDIs configured for the Connection Factory and queue. We need to create links to these objects from the Weblogic server.

Configuration on weblogic server:- 

  • Before starting the weblogic server we need to add some OpenJMS Jars to the Weblogic domain.
  • Edit the <weblogic_domain_home>/bin/setDomainEnv.bat file and at the end add
  • set CLASSPATH=%CLASSPATH%;<OpenJMS_HOME>\lib\castor-0.9.5.jar;<OpenJMS_HOME>\lib\concurrent-1.3.4.jar;<OpenJMS_HOME>\lib\openjms-0.7.7-beta-1.jar;<OpenJMS_HOME>\lib\openjms-common-0.7.7-beta-1.jar;<OpenJMS_HOME>\lib\openjms-net-0.7.7-beta-1.jar;<OpenJMS_HOME>\lib\openjms-tools-0.7.7-beta-1.jar;<OpenJMS_HOME>\lib\spice-jndikit-1.2.jar;
  • Note <OpenJMS_HOME> is the location where you have installed your OpenJMS.
Configuring the OpenJMS JNDI on Weblogic
  • Start your Weblogic server
  • Login into Admin console
  • Goto Services-> Foreign JNDI Providers 
  • Click New, give a valid name and click Next
  • Check the target server(s) and click Finish
  • Click on the newly created Foreign JNDI provider, Click General tab and enter the properties as below
    • Initial Context Factory:  org.exolab.jms.jndi.InitialContextFactory
    • Provider URL:  rmi://localhost:1099/
  • Ignore the other 3 properties and click Save

Now we have configured the OpenJMS JNDI server, Next we need to create links to the JNDI names available on the Open JMS. In our case we have 2 JNDI names available in OpenJMS.
  1. For Queue connection  Factory : "JmsQueueConnectionFactory"
  2. For the queue "queue1"
Creating Links to the JNDI Names
  1. Again goto the newly created connection factory and Click the Links tab
  2. Click New and enter the below details
    • Name: Link1
    • Local JNDI Name: JmsQueueConnectionFactory
    • Remote JNDI Name: JmsQueueConnectionFactory
    1. Click OK
    2. Again Click on New and Enter below details
      • Name: Link2
      • Local JNDI Name: queue1
      • Remote JNDI Name: queue1
    The output should look like below
    That's it the weblogic server configuration is over. Now we can work on our OSB business service.

    Configuring Business Service:-
    1. Create the OBS Configuration and Project and create a business Service.
    2. In the General configuration select "Messaging Service"
    3. Int the Messaging tab select Text for "Request Message Type"
    4. Goto the Transport tab 
      1. Select JMS as protocol.
      2. Enter the Endpoint URI as "jms://localhost:7001/JmsQueueConnectionFactory/queue1" click Add.
    5. Goto "JMS Transport" tab 
      1. Check Queue for destination type
      2. Check Text for Message type
    6. Save the business service and Test it by Run As-> Run On Server from the "Project explorer" view.
    7. When you get the testing browser enter some text in the payload text box and click Execute.
    8. Now the message is sent to the JMS provider. Lets create a small JMS consumer example to consume the message sent

    Consumer Program:- 

    package com.mak.jms;

    import java.util.Hashtable;

    import javax.jms.JMSException;
    import javax.jms.Message;
    import javax.jms.Queue;
    import javax.jms.QueueConnection;
    import javax.jms.QueueConnectionFactory;
    import javax.jms.QueueReceiver;
    import javax.jms.QueueSession;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;

    public class JMSReceiver {
    public static void main(String[] args)
            Hashtable properties = new Hashtable();
        properties.put(Context.PROVIDER_URL, "rmi://localhost:1099/");
        Context context = new InitialContext(properties);
               // retrieve queue connection factory
                  queueConnectionFactory =
               // create a queue connection
               QueueConnection queueConnection =
               // start delivery of incoming messages
               // create a queue session
               // set transactions to false and set auto
               // acknowledgement of receipt of messages
               QueueSession queueSession =
               // retrieve queue
               Queue queue =
               // create a queue receiver and associate
               // to the retrieved queue
               QueueReceiver queueReceiver =
               // receive message using the synchronous
               // receive method
               Message message = queueReceiver.receive();
               String messageText = null;
               if (message instanceof TextMessage)
                  messageText =
            catch (NamingException e)
            catch (JMSException e)

    Add the following below into classpath and run the above code snippet which should display the text sent from the OSB BS.

    That's it. Happy coding. :)

    Sunday, 20 February 2011

    Android Tamil Keyboard

    இன்று தமிழை Android கைபேசியில் உள்ளீடு செய்ய உதவும் மென்பொருளை வெளியிட்டுள்ளேன். இதை பயன்படுத்த Android marketல் Tamil Keyboard என தேடி நிறுவவும். 

    நிறுவிய பிறகு:-
    Goto Settings -> Language & Keyboard -> Tamil Keyboard Enable செய்யவும்.

    இதில் 2 keyboards உள்ளன. ஒன்றிலிருந்து மற்றொன்றிற்கு மாற கீழிருந்து மேல்  swipe செய்யவும். இடைவெளி விட வலமிருந்து இடம் ஒரு சிறிய swipe செய்யவும். 

    மிக்க நன்றி.