c# - 如何使用 HA 配置连接到 IBM MQ Manager?

标签 c# ibm-mq

我正在编写一个 C# 客户端,它使用以下结构使用 amqmdnet.dll 连接到 IBM Websphere MQ Manager:

_myQueueManager = new MQQueueManager(queueManagerName, properties);

在 Hashtable 属性中,我正在设置主机名、 channel 和队列管理器。现在,我怎样才能在我的客户端应用程序中拥有自动重新连接功能?我们有 IBM MQ 多实例队列管理器 HA 配置。

基本上,我有四个端点,如果我的客户端连接失败,我必须回退到这些端点?

最佳答案

根据 the docs :

You can supply a list of hostnames and ports as an argument to the constructor MQQueueManager (String queueManagerName, Hashtable properties) using CONNECTION_NAME_PROPERTY.

For example:

ConnectionName = "fred.mq.com(2344),nick.mq.com(3746),tom.mq.com(4288)";
Hashtable Properties-new Hashtable();
properties.Add(MQC.CONNECTION_NAME_PROPERTY,ConnectionName);
MQQueueManager qmgr=new MQQueue Manager("qmgrname",properties);

When a connection attempt is made, the connection name list is processed in order. If the connection attempt to the first host name and port fails, then connection to the second pair of attributes is attempted. The client repeats this process until either a successful connection is made or the list is exhausted. If the list is exhausted, an appropriate reason code and completion code is returned to the client application.

一定要遵循 Automatic client reconnection in .NET 中的建议确保针对托管/非托管模式正确指定选项。

关于c# - 如何使用 HA 配置连接到 IBM MQ Manager?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42091337/

相关文章:

c# - 入口点在没有构建 IHost 的情况下退出

ibm-mq - IBM Mq 消息头

javax.jms.MessageConsumer 在消费者关闭时挂起接收

c# - 100 分钟后 websphere mq 客户端主题静默访问错误

c# - 应用程序调用了为不同线程编码的接口(interface) - Xamarin Forms

c# - 我怎样才能防止 GDI+ 重新绘制油漆上的所有东西?

c# - asp net css中的响应按钮

c# - 菜单中的连接不起作用

ibm-mq - 我如何知道 MQ 队列管理器何时重新启动?

java - 使用 WebSphere MQ v7.0 找不到 SYSTEM.BROKER 服务