MQRC_ 从 iSeries Websphere 消息队列获取消息时出错
MQRC_ Errors when getting messages from iSeries Websphere Message Queue
我们使用以下代码和设置连接到 iSeries 上的 IBM Websphere Message Queue(版本 IBM(R) WebSphere(R) MQ V6.0.1) .
我们对同一个 MQ 的三个不同应用程序使用相同的 uid 和 pwd
我们全天间歇性地收到 MQRC_NOT_AUTHORIZED
和 MQRC_Q_MGR_NOT_AVAILABLE
错误,但 总是 Get 消息方法。
设置:
连接属性 的哈希表是使用以下设置创建的:
MQC.TRANSPORT_PROPERTY = MQC.TRANSPORT_MQSERIES_MANAGED
MQC.CHANNEL_PROPERTY = SYSTEM.DEF.SVRCONN
MQC.HOST_NAME_PROPERTY = IP Address
我们使用下面的打开选项:
MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE
class WebSphereMQ
{
public bool impStatus { get; set; }
public MQQueueManager gMQQueueManager;
public MQQueue gMQQueue;
private MQMessage queueGetMessage { get; set; }
private MQGetMessageOptions queueGetMessageOptions { get; set; }
public MQQueueManager pMQQueueManager;
public MQQueue pMQQueue;
private MQMessage queuePutMessage { get; set; }
private MQPutMessageOptions queuePutMessageOptions { get; set; }
public WebSphereMQ()
{
impStatus = impersonation.impersonateValidUser(Common.impNme, "", Common.impPwd);
gMQQueueManager = null;
gMQQueue = null;
if (gMQQueue != null && gMQQueue.IsOpen)
{
// Just incase
gMQQueue.Close();
gMQQueueManager.Disconnect();
}
}
public bool connectMQGet(string QMgr, string QName, Hashtable connectionProperties, bool BrowseOnly, string QType)
{
try
{
gMQQueueManager = new MQQueueManager(QMgr, connectionProperties);
if (gMQQueueManager != null && QType == "OUT")
{
if (BrowseOnly)
gMQQueue = gMQQueueManager.AccessQueue(QName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_BROWSE + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE);
else
gMQQueue = gMQQueueManager.AccessQueue(QName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE);
}
}
catch (MQException mqe)
{
if (impStatus) impersonation.undoImpersonation();
/* Write to log */
Common.logBuilder("WebSphereMQ --> connectMQGet <--", "MQException", Common.ActiveMQ, mqe.Message, "Exception");
/* Send email to support */
emailer.exceptionEmail(mqe);
return false;
}
return true;
}
这是错误和堆栈跟踪的示例:
An MQException has happened on 30 June 2015 at 08:52A
Message ---
MQRC_NOT_AUTHORIZED
HelpLink ---
Source ---
amqmdnet
StackTrace ---
at IBM.WMQ.MQBase.throwNewMQException() at IBM.WMQ.MQQueueManager.Connect(String queueManagerName) at IBM.WMQ.MQQueueManager..ctor(String queueManagerName, Hashtable properties) at EvryCardManagement.WebSphereMQ.connectMQGet(String QMgr, String QName, Hashtable connectionProperties, Boolean BrowseOnly, String QType)
那么我可以在客户端更改一些设置以防止我们收到这些异常,或者这是否需要在 iSeries/MQ 上修改?
我们是否应该尝试对访问 MQ 的三个不同应用程序使用不同的 uid?
MQ V6 很久以前就停止服务了。您需要将队列管理器升级到受支持的版本。
对于2035异常有多种解决方法:
1) 您的 MQ .NET 应用程序必须存在于 iSeries 上并且有权连接到队列管理器的用户标识。
2) 在 iSeries 队列管理器上 SYSTEM.DEF.SVRCONN 上设置 MCAUSER。
关于 2035 原因代码的帖子很多。查看来自 T.Rob 的以下帖子以及这些帖子中的链接。
Authorization with Websphere MQ 6
WebSphere 7, configuring JMS Q connection factory without user id: MQRC_NOT_AUTHORIZED
我们使用以下代码和设置连接到 iSeries 上的 IBM Websphere Message Queue(版本 IBM(R) WebSphere(R) MQ V6.0.1) .
我们对同一个 MQ 的三个不同应用程序使用相同的 uid 和 pwd
我们全天间歇性地收到 MQRC_NOT_AUTHORIZED
和 MQRC_Q_MGR_NOT_AVAILABLE
错误,但 总是 Get 消息方法。
设置:
连接属性 的哈希表是使用以下设置创建的:
MQC.TRANSPORT_PROPERTY = MQC.TRANSPORT_MQSERIES_MANAGED
MQC.CHANNEL_PROPERTY = SYSTEM.DEF.SVRCONN
MQC.HOST_NAME_PROPERTY = IP Address
我们使用下面的打开选项:
MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE
class WebSphereMQ
{
public bool impStatus { get; set; }
public MQQueueManager gMQQueueManager;
public MQQueue gMQQueue;
private MQMessage queueGetMessage { get; set; }
private MQGetMessageOptions queueGetMessageOptions { get; set; }
public MQQueueManager pMQQueueManager;
public MQQueue pMQQueue;
private MQMessage queuePutMessage { get; set; }
private MQPutMessageOptions queuePutMessageOptions { get; set; }
public WebSphereMQ()
{
impStatus = impersonation.impersonateValidUser(Common.impNme, "", Common.impPwd);
gMQQueueManager = null;
gMQQueue = null;
if (gMQQueue != null && gMQQueue.IsOpen)
{
// Just incase
gMQQueue.Close();
gMQQueueManager.Disconnect();
}
}
public bool connectMQGet(string QMgr, string QName, Hashtable connectionProperties, bool BrowseOnly, string QType)
{
try
{
gMQQueueManager = new MQQueueManager(QMgr, connectionProperties);
if (gMQQueueManager != null && QType == "OUT")
{
if (BrowseOnly)
gMQQueue = gMQQueueManager.AccessQueue(QName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_BROWSE + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE);
else
gMQQueue = gMQQueueManager.AccessQueue(QName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE);
}
}
catch (MQException mqe)
{
if (impStatus) impersonation.undoImpersonation();
/* Write to log */
Common.logBuilder("WebSphereMQ --> connectMQGet <--", "MQException", Common.ActiveMQ, mqe.Message, "Exception");
/* Send email to support */
emailer.exceptionEmail(mqe);
return false;
}
return true;
}
这是错误和堆栈跟踪的示例:
An MQException has happened on 30 June 2015 at 08:52A
Message ---
MQRC_NOT_AUTHORIZED
HelpLink ---
Source ---
amqmdnet
StackTrace ---
at IBM.WMQ.MQBase.throwNewMQException() at IBM.WMQ.MQQueueManager.Connect(String queueManagerName) at IBM.WMQ.MQQueueManager..ctor(String queueManagerName, Hashtable properties) at EvryCardManagement.WebSphereMQ.connectMQGet(String QMgr, String QName, Hashtable connectionProperties, Boolean BrowseOnly, String QType)
那么我可以在客户端更改一些设置以防止我们收到这些异常,或者这是否需要在 iSeries/MQ 上修改?
我们是否应该尝试对访问 MQ 的三个不同应用程序使用不同的 uid?
MQ V6 很久以前就停止服务了。您需要将队列管理器升级到受支持的版本。
对于2035异常有多种解决方法:
1) 您的 MQ .NET 应用程序必须存在于 iSeries 上并且有权连接到队列管理器的用户标识。
2) 在 iSeries 队列管理器上 SYSTEM.DEF.SVRCONN 上设置 MCAUSER。
关于 2035 原因代码的帖子很多。查看来自 T.Rob 的以下帖子以及这些帖子中的链接。
Authorization with Websphere MQ 6
WebSphere 7, configuring JMS Q connection factory without user id: MQRC_NOT_AUTHORIZED