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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20