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 |
|
|
public static void closeQueueSafe(MQQueue queue)
|
11 |
|
|
{
|
12 |
|
|
if (queue != null && queue.IsOpen)
|
13 |
|
|
{
|
14 |
|
|
try
|
15 |
|
|
{
|
16 |
|
|
queue.Close();
|
17 |
|
|
}
|
18 |
|
|
catch (Exception e)
|
19 |
|
|
{
|
20 |
|
|
Console.WriteLine("Error cleaning up queue " + e.Message);
|
21 |
|
|
}
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
public static void closeQueueManagerSafe(MQQueueManager mqMgr)
|
27 |
|
|
{
|
28 |
|
|
if (mqMgr != null && mqMgr.IsOpen)
|
29 |
|
|
{
|
30 |
|
|
try
|
31 |
|
|
{
|
32 |
|
|
mqMgr.Close();
|
33 |
|
|
}
|
34 |
|
|
catch (Exception e)
|
35 |
|
|
{
|
36 |
|
|
Console.WriteLine("Error cleaning up qmgr " + e.Message);
|
37 |
|
|
}
|
38 |
|
|
}
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
public static Hashtable getConnectionProperties(string mqHost, string mqChannel)
|
42 |
|
|
{
|
43 |
|
|
Hashtable connProperties = new Hashtable();
|
44 |
|
|
connProperties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);
|
45 |
|
|
connProperties.Add(MQC.HOST_NAME_PROPERTY, mqHost);
|
46 |
|
|
connProperties.Add(MQC.CHANNEL_PROPERTY, mqChannel);
|
47 |
|
|
return connProperties;
|
48 |
|
|
}
|
49 |
|
|
}
|
50 |
|
|
}
|