import com.ibm.mq.*; //Include the WebSphere MQ classes for Java package
public class MQReceiver {
// define the name of the QueueManager
private static String qManager;
// and define the name of the Queue
private static String qName;
// main method: simply call the runReceiver() method
public static void main(String args[]) {
if (args == null || args.length != 1) {
System.out.println("needs one argument: <Queue Name>");
System.exit (0);
}
new MQReceiver().runReceiver(args);
}
public void runReceiver(String args[]) {
qName = args[0];
qManager = System.getProperty ("message.queue.manager");
try {
// Create a connection to the QueueManager
System.out.println("Connecting to queue manager: "+qManager);
MQEnvironment.channel = System.getProperty ("message.chanel.name");
MQEnvironment.hostname = System.getProperty ("message.queue.server");
MQEnvironment.port = new Integer ((System.getProperty ("message.queue.port"))).intValue();
MQEnvironment.CCSID = new Integer ((System.getProperty ("message.queue.ccsid"))).intValue();
MQQueueManager qMgr = new MQQueueManager(qManager);
// Now specify the queue that we wish to open and the open options
System.out.println("Accessing queue: "+qName);
// Now get the message back again. First define a WebSphere MQ message
// to receive the data
MQMessage rcvMessage = new MQMessage();
// Specify default get message options
MQGetMessageOptions gmo = new MQGetMessageOptions();
// Set up the options on the queue we wish to open
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_FAIL_IF_QUIESCING;
MQQueue queue = qMgr.accessQueue(qName, openOptions);
while (true) {
// Get the message off the queue.
gmo.options = MQC.MQGMO_WAIT | MQC.MQGMO_CONVERT;
gmo.waitInterval = 15000000; // 15000 seconds
gmo.matchOptions = MQC.MQMO_NONE;
rcvMessage.correlationId = MQC.MQCI_NONE;
rcvMessage.messageId = MQC.MQMI_NONE;
rcvMessage.groupId = MQC.MQGI_NONE;
rcvMessage.clearMessage();
queue.get(rcvMessage, gmo);
// String msgText = rcvMessage.readUTF();
String msgText = rcvMessage.readStringOfByteLength( rcvMessage.getMessageLength( ) );
System.out.println("The message is: " + msgText);
if (msgText.equals ("exit"))
break;
}
// Close the queue
System.out.println("Closing the queue");
queue.close();
// Disconnect from the QueueManager
System.out.println("Disconnecting from the Queue Manager");
qMgr.disconnect();
System.out.println("Done!");
}
catch (MQException ex) {
System.out.println("A WebSphere MQ Error occured : Completion Code "
+ ex.completionCode + " Reason Code " + ex.reasonCode);
}
catch (java.io.IOException ex) {
System.out.println("An IOException occured whilst writing to the message buffer: "
+ ex);
}
}
}
分享到:
相关推荐
IBM-MQ-Explorer-Win64,MQ图形界面、基于eclipse
ibm-mq里面的ibm-mq-jmqi-7.5.RELEASE.jar下载,有需要的可以直接下载,亲自测过可以正常使用。
IBM MQ 7.5.0 windows版本全部仅需要一次下载即可使用
ibm-mq里面的ibm-mq-commonservices-7.5.RELEASE.jar下载,有需要的可以直接下载,亲自测过可以正常使用。
JAVA IBM MQ 接收消息、发送消息例子
IBM-MQ java所需要jar包,需要的自取,一共有aspectjrt,com.ibm.mq.fta,com.ibm.mq,com.ibm.mq.jms.Nojndi,com.ibm.mq.soap,com.ibm.mqetclient,com.ibm.mqjms,connector
IBMMQ消息序号-顺序
Java连接IBM WebSphere MQ 7处理队列信息所需jar包,从安装目录直接打的包。主要包括: /com.ibm.mq.commonservices.jar /com.ibm.mq.defaultconfig.jar /com.ibm.mq.fta.jar /com.ibm.mq.headers.jar /...
IBM存储管理软件 ibm_sw_ds3-5k_10.86.x5.35_windows_x64
IBM DS系列存储管理软件安装包 ibm_sw_ds3-5k_10.77.xx.28_windows_x64
IBM WEBSPHERE MQ 客户端--服务器端安装配置
ibm-java-sdk-8.0-5.11-x86_64-archive.bin ibm的jdk 8.0版本
ibm_sw_ds3-5k_10.84.xx.30_windows_intl386
基本涵盖了IBMMQ开发所需的mq 依赖包,java连接ibm mq所需要的依赖包
IBMMQ 7.0.1.3 相关jar包 1. com.ibm.mq-7.0.1.3.jar 2. com.ibm.mq.jmqi-7.0.1.3.jar 3. com.ibm.mqjms-7.0.1.3.jar 4. dhbcore-7.0.1.3.jar
IBM_MQ_9.1.5_LINUX_X86-64_TRIAL.tar.gz
ibm_fw_ds3-5k_07772000_anyos_anycpu.ZIP 目前已知的最低版本,测试过DS3512成功,内含nvsram和FW ibm_fw_ds3-5k_07772000_anyos_anycpu.ZIP 目前已知的最低版本,测试过DS3512成功,内含nvsram和FW ibm_fw_ds3-...
IBM MQ安装 IBM MQ - Websphere MQ BM MQ 使用消息队列促进信息交换,并为云、移动、物联网和本地环境提供消息传递解决方案。
1) 本工程主要演示在SPRING BOOT工程中怎样使用JMS集成IBM-MQ及TLQ两种消息中间件产品 2) 使用SPRING BOOT Conditional机制实现了两种产品按需加载,工程会根据配置文件开关动态加载 3) 实现了普通队列消息发送与...
废话不多说,com.ibm.mq.jar.zip IBMMQ 需要的下载