/[projects]/miscJava/thn_mqutils/src/com/traiana/utils/mq/MQ.java
ViewVC logotype

Contents of /miscJava/thn_mqutils/src/com/traiana/utils/mq/MQ.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1980 - (show annotations) (download)
Fri May 10 09:16:32 2013 UTC (11 years ago) by torben
File size: 2869 byte(s)
Initial import
1 /* */ package com.traiana.utils.mq;
2 /* */
3 /* */ import com.ibm.mq.MQEnvironment;
4 /* */ import com.ibm.mq.MQException;
5 /* */ import com.ibm.mq.MQMessage;
6 /* */ import com.ibm.mq.MQQueue;
7 /* */ import com.ibm.mq.MQQueueManager;
8 /* */ import java.io.IOException;
9 /* */ import java.io.OutputStreamWriter;
10 import java.util.Hashtable;
11 /* */
12 /* */ public class MQ
13 /* */ {
14 /* */ MQQueueManager _qMgr;
15 /* */ MQQueue _mQQueue;
16 /* */
17 /* */ @SuppressWarnings("unchecked")
18 public MQ(String qmgr, int port, String mqServerName, String channelName, int ccsid, boolean log)
19 /* */ throws MQException
20 /* */ {
21 /* 36 */ MQEnvironment.hostname = mqServerName;
22 /* 37 */ MQEnvironment.port = port;
23 /* 38 */ MQEnvironment.channel = channelName;
24 /* 39 */ MQEnvironment.properties.put("transport", "MQSeries Client");
25
26 /* */
27 /* 41 */ if (log)
28 /* 42 */ MQException.log = new OutputStreamWriter(System.out);
29 /* */ else {
30 /* 44 */ MQException.log = new OutputStreamWriter(new NullOutputStream());
31 /* */ }
32 /* 46 */ if (ccsid > 0)
33 /* 47 */ MQEnvironment.properties.put("CCSID", new Integer(ccsid));
34 /* */ try {
35 /* 49 */ this._qMgr = new MQQueueManager(qmgr);
36 /* */ } catch (MQException e) {
37 /* 51 */ e.printStackTrace();
38 /* */ }
39 /* */ }
40 /* */
41 /* */ public void InitQueue(String queueName) throws MQException {
42 /* 56 */ InitQueue(queueName, false);
43 /* */ }
44 /* */
45 /* */ public void InitQueue(String queueName, boolean depth)
46 /* */ throws MQException
47 /* */ {
48 /* 62 */ int openOptions = depth ? 32 : 16;
49 /* */
50 /* 64 */ if (this._mQQueue != null) {
51 /* 65 */ this._mQQueue.close();
52 /* 66 */ this._mQQueue = null;
53 /* */ }
54 /* 68 */ this._mQQueue = this._qMgr.accessQueue(queueName, openOptions);
55 /* */ }
56 /* */
57 /* */ public int getDepth() throws MQException
58 /* */ {
59 /* 73 */ return this._mQQueue.getCurrentDepth();
60 /* */ }
61 /* */
62 /* */ public void sendToQueue(byte[] message)
63 /* */ throws MQException, IOException
64 /* */ {
65 /* 84 */ MQMessage mQMessage = new MQMessage();
66 /* 85 */ mQMessage.format = new String("MQSTR ");
67 /* 86 */ mQMessage.clearMessage();
68 /* 87 */ mQMessage.write(message);
69 /* 88 */ this._mQQueue.put(mQMessage);
70 /* */ }
71 /* */
72 /* */ public void close() throws MQException {
73 /* 92 */ if (this._mQQueue != null)
74 /* 93 */ this._mQQueue.close();
75 /* 94 */ this._qMgr.disconnect();
76 /* 95 */ this._qMgr.close();
77 /* */ }
78 /* */ }
79
80 /* Location: C:\Users\thn\workspace\mq-utils.jar
81 * Qualified Name: com.traiana.utils.mq.MQ
82 * JD-Core Version: 0.6.2
83 */

  ViewVC Help
Powered by ViewVC 1.1.20