WMQ
配置
- HostName
- Channel
- 队列管理器之间单向点对点通信连接,消息在通道中单向流动
- Port
- QueueManager
- 消息队列的管理者
- ConnectionNameList
- 集群cluster,一个队列管理器属于多个集群
- ClientReconnectOptions
- CCSID
- TransportType
API
依赖:
* mq-x
* connector-x
* jmqi-x
* commonservices-x
* headers-x
* mqjms-x
public static void send(String qName, String msg) throws MQException, IOException {
Hashtable<String, Object> properties = new Hashtable<String, Object>();
properties.put(MQConstants.CONNECT_OPTIONS_PROPERTY, MQConstants.MQCNO_RECONNECT);
properties.put(MQConstants.HOST_NAME_PROPERTY, connectionName);
properties.put(MQConstants.PORT_PROPERTY, port);
properties.put(MQConstants.CHANNEL_PROPERTY, channel);
properties.put(MQConstants.CCSID_PROPERTY, ccsid);
MQQueueManager queueMgr = new MQQueueManager(qManager, properties);
MQQueue queue = queueMgr.accessQueue(qName, openOptions, null, null, null);
MQMessage outMsg = new MQMessage();
outMsg.write(msg.getBytes("UTF-8"));
queue.put(outMsg, new MQPutMessageOptions());
queueMgr.commit();
queue.close();
queueMgr.disConnect();
}
连接池
缺省情况下,每次new MQQueueManger()调用都意味着应用程序与队列管理器多了一条连接,在MQ Clinet/Server 结构中表现为多了一条TCP/IP连接。每次MQQueueManger.disconnect()时这条连接断开,即为TCP/IP连接断开。例如,在同一个线程中,如果反复连接再断开M