/* */ package com.traiana.utils.mq; /* */ /* */ import com.ibm.mq.MQEnvironment; /* */ import com.ibm.mq.MQException; /* */ import com.ibm.mq.MQMessage; /* */ import com.ibm.mq.MQQueue; /* */ import com.ibm.mq.MQQueueManager; /* */ import java.io.IOException; /* */ import java.io.OutputStreamWriter; import java.util.Hashtable; /* */ /* */ public class MQ /* */ { /* */ MQQueueManager _qMgr; /* */ MQQueue _mQQueue; /* */ /* */ @SuppressWarnings("unchecked") public MQ(String qmgr, int port, String mqServerName, String channelName, int ccsid, boolean log) /* */ throws MQException /* */ { /* 36 */ MQEnvironment.hostname = mqServerName; /* 37 */ MQEnvironment.port = port; /* 38 */ MQEnvironment.channel = channelName; /* 39 */ MQEnvironment.properties.put("transport", "MQSeries Client"); /* */ /* 41 */ if (log) /* 42 */ MQException.log = new OutputStreamWriter(System.out); /* */ else { /* 44 */ MQException.log = new OutputStreamWriter(new NullOutputStream()); /* */ } /* 46 */ if (ccsid > 0) /* 47 */ MQEnvironment.properties.put("CCSID", new Integer(ccsid)); /* */ try { /* 49 */ this._qMgr = new MQQueueManager(qmgr); /* */ } catch (MQException e) { /* 51 */ e.printStackTrace(); /* */ } /* */ } /* */ /* */ public void InitQueue(String queueName) throws MQException { /* 56 */ InitQueue(queueName, false); /* */ } /* */ /* */ public void InitQueue(String queueName, boolean depth) /* */ throws MQException /* */ { /* 62 */ int openOptions = depth ? 32 : 16; /* */ /* 64 */ if (this._mQQueue != null) { /* 65 */ this._mQQueue.close(); /* 66 */ this._mQQueue = null; /* */ } /* 68 */ this._mQQueue = this._qMgr.accessQueue(queueName, openOptions); /* */ } /* */ /* */ public int getDepth() throws MQException /* */ { /* 73 */ return this._mQQueue.getCurrentDepth(); /* */ } /* */ /* */ public void sendToQueue(byte[] message) /* */ throws MQException, IOException /* */ { /* 84 */ MQMessage mQMessage = new MQMessage(); /* 85 */ mQMessage.format = new String("MQSTR "); /* 86 */ mQMessage.clearMessage(); /* 87 */ mQMessage.write(message); /* 88 */ this._mQQueue.put(mQMessage); /* */ } /* */ /* */ public void close() throws MQException { /* 92 */ if (this._mQQueue != null) /* 93 */ this._mQQueue.close(); /* 94 */ this._qMgr.disconnect(); /* 95 */ this._qMgr.close(); /* */ } /* */ } /* Location: C:\Users\thn\workspace\mq-utils.jar * Qualified Name: com.traiana.utils.mq.MQ * JD-Core Version: 0.6.2 */