【问题标题】:How to convert a MQseries reason code to string?如何将 MQseries 原因代码转换为字符串?
【发布时间】:2019-06-28 22:24:27
【问题描述】:

如何将 IBM Websphere MQseries 的原因代码转换/查找为其解释(用于日志记录等)?

【问题讨论】:

    标签: c++ c ibm-mq


    【解决方案1】:

    请参阅SupportPac MA0K,它有 C 和 Visual Basic 代码来执行此任务。

    【讨论】:

    • 太棒了!我想知道在哪里可以找到这个 - 为我节省了很多工作,@T.Rob
    【解决方案2】:

    从命令行有“mqrc.exe”,它与 MQSeries 一起提供,它返回符号常量名称。

    对于 Java,com.ibm.mq.jmqi.jar 中包含 MQConstants.lookupReasonCode(reasonCode)

    【讨论】:

      【解决方案3】:

      尝试使用 IBM Websphere MQ api:char *MQRC_STR (MQLONG ReasonCode)

      这里是示例代码:

          #include <cmqc.h>
          #include <cmqstrc.h>
          typedef MQHCONN QM_REF;
      
          QM_REF connect(const std::string & QueueManagerName)
          {
              QM_REF theManager_ = -1;
      
              MQLONG compCode, reasonCode;
              MQCONN(const_cast<char *>(QueueManagerName.c_str()), &theManager_, &compCode, &reasonCode);
              if (MQCC_FAILED == compCode)
              {
                  std::cout << "Failed to connect to queue manager. Reason code is:" << MQRC_STR(reasonCode) << std::endl;
              }
      
              return theManager_;
          }
      

      【讨论】:

      • 为什么投反对票?这显示了如何使用在 2010 年提出此问题时尚未出现的最新版本 IBM MQ 中添加的功能。
      • 将标准输出用于错误报告是一个主要反模式:(这就是标准错误的用途。
      猜你喜欢
      • 1970-01-01
      • 2011-12-06
      • 2018-11-13
      • 1970-01-01
      • 2021-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多