Install WebSphere MQ Explorer in Eclipse

Home > Search
  by

Eclipse is going to need the MQExplorerSDK.zip file to install the com.ibm.mq packages. To get MQExplorerSDK.zip, on the MQ Server, install the MQ Series JRE and MQ Series Explorer packages. After these packages are installed, copy the MQExplorerSDK.zip folder from the /opt/mqm/mqexplorer/eclipse directory to the machine that is running Eclipse.

~]# cd /opt/MQServer
~]# rpm -ivh MQSeriesJRE-<version>
~]# rpm -ivh MQSeriesExplorer-<version>

 

Install IBM MQ Explorer.

  1. In Eclipse, select Help > Install New Software.
  2. Select Add.
  3. Select Archive.
  4. Select MQExplorerSDK.zip.
  5. Check IBM MQ Explorer.
  6. Select Next.
  7. Select Next.
  8. Select Finish.

 

Setup Eclipse.

  1. In Eclipse, select  File > New > Java Project.
  2. Give your project a name, such as myMQProject and select Finish.
  3. In the left panel of Eclipse, expand myMQProject, right-click on the src folder and select New > Class.
  4. Give the new class a name, such as SimpleJMSProducer, and select Finish.
  5. Add the following markup.
    • Replace MANAGER01 with the name of your WebSphere MQ manager.

This code was created by Riyafa Abdul Hameed - https://riyafa.wordpress.com/2016/02/21/sample-java-client-for-websphere-mq-consumer-and-producer/

import com.ibm.mq.MQException;
import com.ibm.mq.constants.CMQC;
import com.ibm.mq.MQMessage;
import com.ibm.mq.MQPutMessageOptions;
import com.ibm.mq.MQQueue;
import com.ibm.mq.MQQueueManager;
import java.io.IOException;

public class SimpleJMSProducer
{
    public void sendMsg(String msg)
    {
        MQQueueManager queueManager = null;
        MQMessage mqMessage = null;
        MQPutMessageOptions myPMO = null;

        try
        {

            // creating queue manager
            queueManager = new MQQueueManager("MANAGER01");

            // creating queue`
            MQQueue queue = queueManager.accessQueue("MQ.REQUEST", CMQC.MQOO_OUTPUT);

            // configuring message encoding, character set, and format
            mqMessage = new MQMessage();
            mqMessage.encoding = new Integer("546");
            mqMessage.characterSet = new Integer("1208");
            mqMessage.format = "MQSTR";

            // sending message
            mqMessage.writeString(msg);
            myPMO = new MQPutMessageOptions();
            queue.put(mqMessage, myPMO);
            
            // Closing Queue after putting message
            queue.close();

        } catch (MQException | NumberFormatException | IOException je)
        {
            je.printStackTrace(System.err);
        } finally
        {
            if (queueManager != null) try
            {
                // Disconnecting queue manager
                queueManager.disconnect();
            } catch (MQException ex) {
                ex.printStackTrace(System.err);
            } 
        }
    }

    public static void main(String[] args)
    {
        new SimpleJMSProducer().sendMsg("Hello world!!!");
    }
}
  1. Select the green play button, and ensure Hello World is displayed in the console, and a pop-up box with text How are you today should also appear.

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments