Loading
WebSphere MQ integration Example

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  WebSphere MQ integration Example


  • WebSphere MQ integration Example
    Sample Img 2

Ans)

WebSphere MQ is one of the very popular MOM server which has been used by enormous number of
Organizations as their message based integrator .

The following code snippets and images illustrates how could the Web Sphere app server be integrated with
WebSphere MQ.

Step 1:

Create a Queue Connection Factory:



Queue manager : The Queue manager name  (MQ Queue manager )

Hostname :   The host name where you installed MQ

Server connection channel :   SYSTEM.ADMIN.SVRCONN (this is generic Remote Queue Channel name in MQ)

 Step 2:

Websphere queue :

WebSphere Queue
      set up


Queue name  : Queue of the MQ queue   
Queue manager or Queue sharing group name  :  MQ Queue Manager Name

 

Code :

Please note you are submitting your message to WebSphere , that would in-turn submit the data
to  WebSphere-MQ , you are not directly submitting data to  WebSphere-MQ.


public static void sendMessage(String inputXML)
  {
    try
    {
     String URL = "iiop://w108v-wp2-015:2809";

    String connectionfactoryjndi = "test/JMSCF";

    String sendQueueName = "test/gcJMSQ";

      Properties props = new Properties();
      props.setProperty("java.naming.factory.initial", "com.ibm.websphere.naming.WsnInitialContextFactory");

      props.setProperty("java.naming.provider.url", URL);

      Context jndiContext = new InitialContext();
      jndiContext = new InitialContext(props);

      QueueConnectionFactory cf = (QueueConnectionFactory)jndiContext.lookup(connectionfactoryjndi);
      System.out.println("Looked up : QueueConnectionFactory " + connectionfactoryjndi);
      System.out.println("Transport CCC Queue [" + sendQueueName + "]");

      QueueConnection connection = cf.createQueueConnection();
      QueueSession session = connection.createQueueSession(false, 2);
      Queue queue = (Queue)jndiContext.lookup(sendQueueName);
      QueueSender sender = session.createSender(queue);

      long uniqueNumber = System.currentTimeMillis() % 1000L;
      TextMessage message = session.createTextMessage(inputXML);

      connection.start();

      sender.send(message);

      sender.close();

      session.close();
      connection.close();

      System.out.println("\\nSUCCESS\\n");
    }
    catch (JMSException jmsex) {
      System.out.println(jmsex);
      System.out.println("\\nFAILURE\\n");
    }
    catch (Exception ex) {
      System.out.println(ex);
      System.out.println("\\nFAILURE\\n");
    }
  }

 



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

WebSphere MQ integration Example


WebSphere MQ integration Example

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free