我想连接到具有此信息的mqseries服务器
服务器名称:“ myServerName”
我还需要了解队列管理器吗?或者我可以使用“默认”,我也收到此错误消息
无法加载DLL'mqic32.dll'或其依赖项之一: 指定的模块无法找到。 (来自HRESULT的异常: 0x8007007E)'
static MQQueueManager queueManager;
static MQQueueManager qManager;
static MQQueue queue;
MQMessage queueMessage;
MQGetMessageOptions queueGetMessageOptions;
MQPutMessageOptions queuePutMessageOptions;
static string QueueName;
static void Main(string[] args)
{
Connect();
}
static void Connect()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("AppSettings.json", true, true).Build();
// Read the Mqseries "connection string" from App.config file.
var queueManagerName = builder["queueManagerName"];
var MQChannel = builder["MQChannel"];
var queueName = builder["QueueName"];
string connectionName = builder["ConnectionName"];
MQAccess(queueName, "Default", connectionName, MQChannel);
Console.WriteLine("Connected to MQ Queue Manager");
}
public static void MQAccess(string queueName, string queueManager, string connection, string channel)
{
QueueName = queueName;
qManager = new MQQueueManager(queueManager, channel, connection);
queue = qManager.AccessQueue(QueueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
}
答案 0 :(得分:1)
.NET核心支持已在MQ v9.1.1中添加。再次如@JasonE所述,您只需要使用MQ .NET托管模式。
示例代码:
Hashtable properties;
MQQueueManager queueManager = null;
try {
properties = new Hashtable();
properties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
properties.Add(MQC.HOST_NAME_PROPERTY, hostName);
properties.Add(MQC.PORT_PROPERTY, port);
properties.Add(MQC.CHANNEL_PROPERTY, channelName);
properties.Add(MQC.USER_ID_PROPERTY, userName);
properties.Add(MQC.PASSWORD_PROPERTY, pwd);
MQQueueManager queueManager = new MQQueueManager(queueManagerName, properties);
}catch(MQException mqex) {
// Console out exception
}