/[projects]/dao/DaoMqPump2/DaoCommon/MQHelper.cs
ViewVC logotype

Contents of /dao/DaoMqPump2/DaoCommon/MQHelper.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2175 - (show annotations) (download)
Mon May 19 11:59:45 2014 UTC (10 years ago) by torben
File size: 1769 byte(s)
Better handling of openQueue exceptions
1 using System;
2
3 using IBM.WMQ;
4 using System.Collections;
5
6 namespace DaoCommon
7 {
8 public class MQHelper
9 {
10 public static MQQueue openQueueHelper(string queueName, MQQueueManager mqMgr, int openOptions)
11 {
12 try
13 {
14 return mqMgr.AccessQueue(queueName, openOptions);
15 } catch (MQException e) {
16 throw new Exception("Error opening queue " + queueName + ": " + e.Message, e);
17 }
18 }
19
20 public static void closeQueueSafe(MQQueue queue)
21 {
22 if (queue != null && queue.IsOpen)
23 {
24 try
25 {
26 queue.Close();
27 }
28 catch (Exception e)
29 {
30 Console.WriteLine("Error cleaning up queue " + e.Message);
31 }
32 }
33
34 }
35
36 public static void closeQueueManagerSafe(MQQueueManager mqMgr)
37 {
38 if (mqMgr != null && mqMgr.IsOpen)
39 {
40 try
41 {
42 mqMgr.Close();
43 }
44 catch (Exception e)
45 {
46 Console.WriteLine("Error cleaning up qmgr " + e.Message);
47 }
48 }
49 }
50
51 public static Hashtable getConnectionProperties(string mqHost, string mqChannel)
52 {
53 Hashtable connProperties = new Hashtable();
54 connProperties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);
55 connProperties.Add(MQC.HOST_NAME_PROPERTY, mqHost);
56 connProperties.Add(MQC.CHANNEL_PROPERTY, mqChannel);
57 return connProperties;
58 }
59 }
60 }

  ViewVC Help
Powered by ViewVC 1.1.20