Discussions

EJB programming & troubleshooting: How to use MQSeries with java

  1. How to use MQSeries with java (3 messages)

    I m developing a message oriented middleware with JMS and I want to use the functionality of MQSeries any ressources about this

    Threaded Messages (3)

  2. How to use MQSeries with java[ Go to top ]

    HI THERE
    IBM do provied the thing called Red books
    there is also standerd API for java to be used with MQ series,also please tell me more about this project so that we can discuss more on this.

    Cheers
    Manoj
  3. Well, IBM provides two types of Java Bindings
    1. MQI Java Bindings
    2. JMS Implementation

    Based on the need you can use either or both.

    These apis are free for development and is provided with the MQSeries CD, if you have bought.
    If you need links for downloading and installation, then follow this link. (copy and paste on ur fav. browser.)

    Down load the MQI for Java.
      MQSeries
    SupportPac MA88: MQSeries classes for Java and MQSeries classes for Java Messaging

    http://www14.software.ibm.com/webapp/download/product.jsp?cat=ts&s=s&id=TDUN-49EVER&pf=&presb=&type=s&postsb=

    Sample Program
    import com.ibm.mq.*;
    import com.ibm.mq.pcf.*;
    import java.io.*;
    public class MQConnector
    {
    private PCFAgent connectorAgent;
    private static final String Q_MANAGER="QM_ganesh";
    private static final String Q_LOCAL="XML_Q";

    public MQConnector() throws MQException, IOException
    {
    PCFAgent agent = new PCFAgent ("<host name>", 1414, "ORDERS");
      MQMessage [] responses;
      PCFParameter [] parameters =
      {
      new MQCFST (CMQC.MQCA_Q_NAME, "*"),
      new MQCFIN (CMQC.MQIA_Q_TYPE, MQC.MQQT_LOCAL)
      };
    MQCFH cfh;
      MQCFSL cfsl;
     
      responses = agent.send (CMQCFC.MQCMD_INQUIRE_Q_NAMES, parameters);
     
      cfh = new MQCFH (responses [0]);
     
      if (cfh.reason == 0)
      {
      cfsl = new MQCFSL (responses [0]);
     
      for (int i = 0; i < cfsl.strings.length; i++)
      {
      System.out.println ("Queue: " + cfsl.strings [i]);
      }
    }
      else
      {
    throw new MQException (cfh.compCode, cfh.reason, agent);
      }
     


    }
    public static void main(String[] args)
    {
    try
    {
    MQConnector mq=new MQConnector();
    }
    catch(MQException mqe)
    {
    mqe.printStackTrace();
    }
    catch(IOException ioe)
    {
    ioe.printStackTrace();
    }

    }

    }

    If you use the JMS version (where u create topic connection factory or Queue Connection factory, then u will be using JMS version.

    IF you are using J2EE architecture, u can extend Message Driven Bean with MQSeries JMS impl or Session beans can invoke hellper classes which actually connect to MQSeries and do a put and get message (two famous operation on MOM).



    Hope this helps and my two cents ..



    Thanks
    Sudhen




  4. "u can extend Message Driven Bean with MQSeries JMS impl or Session beans can invoke hellper classes which actually connect to MQSeries and do a put and get message (two famous operation on MOM)."

    Where can I get information or read more about this?