代码之家  ›  专栏  ›  技术社区  ›  Joe Schmoe

使用C#和.Net连接到远程队列管理器

  •  6
  • Joe Schmoe  · 技术社区  · 15 年前

    我使用以下函数调用编写了一个连接到本地队列管理器的应用程序:

    MQQueueManager mqQMgr = new MQQueueManager("QM_QueueManagerName");
    

    现在我需要连接到另一台计算机上的远程队列管理器。

    我可以使用MQ Explorer从开发PC成功地连接到远程队列管理器 QM_ComputerName 作为队列管理器名称, S_ComputerName

    然而,当我试图通过.Net连接时 MQRC_Q_MGR_NAME_ERROR 不管我怎么努力。

    我试着说明

    MQEnvironment.Hostname = "ComputerName";
    MQEnvironment.Channel = "S_ComputerName ";
    
    and then calling
    
    mqQMgr = new MQQueueManager("QM_ComputerName");
    
    I also tried  calling 
    
    mqQMgr = new MQQueueManager("QM_ComputerName", "S_ComputerName", "ComputerName");
    

    两种情况下我都会出错。

    有人能建议吗?

    2 回复  |  直到 15 年前
        1
  •  3
  •   T.Rob    7 年前

    也许 this sample code

    我链接到V7文档。理想情况下,您将同时使用V7客户机和V7服务器,因为与V6相比,.Net功能有了很大的改进。另外,V6在2011年9月就已经停止使用了,所以现在直接使用v7并避免以后的升级是很好的。

    IBM MQ Client Downloads 页面(需要IBM ID,但是免费下载的)。

    更新20180810: 更改了指向IBM所有IBM MQ客户端下载的新页面的链接。

        2
  •  4
  •   Morvader Ray James    15 年前

     MQQueueManager mqQMgr=null;
    
       Hashtable props = new Hashtable();
    
    props.Add(MQC.HOST_NAME_PROPERTY, "HostNameOrIP");
    
       props.Add(MQC.CHANNEL_PROPERTY, "ChannelName");
    
       props.Add(MQC.PORT_PROPERTY, 1414); // port number
    
       props.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
    
       MQQueue mqQueue = null;
    
       try
    
       {
    
          mqQMgr = new  MQQueueManager("QueueManagerName", props);
    
          mqQueue = mqQMgr.AccessQueue(
                   QueueName,
                   MQC.MQOO_OUTPUT                   // open queue for output
                   + MQC.MQOO_FAIL_IF_QUIESCING);   // but not if MQM stopping
       }
    
       catch (MQException mqe1)
    
       {
    
       }
    
    推荐文章