我有一个 XMS MQ 客户端应用程序,它从一系列 MQ 端点提取消息。对于某些原因代码,该过程可以继续,而对于某些原因代码,它应该中止。例如MQRC_Q_MGR_NOT_AVAILABLE
,一个端点的 2059 不应中止整个过程。因此,我想检查这个原因代码。
cf = factoryFactory.CreateConnectionFactory();
foreach (Endpoint e in env.GetEndpoints())
{
Console.WriteLine("Consuming messages from endpoint {0}({1})", e.host, e.port);
// Set the properties
SetConnectionProperties(cf, e);
try
{
ReceiveMessagesFromEndpoint(cf);
}
catch (XMSException ex)
{
Console.WriteLine("XMSException caught: {0}", ex);
Console.WriteLine("Error Code: {0}", ex.ErrorCode);
Console.WriteLine("Error Message: {0}", ex.Message);
}
}
问题是 XMSException 上唯一可以检查的属性是ex.ErrorCode
和ex.Message
,它们分别是:
Error Code: CWSMQ0006
和
Error Message: CWSMQ0006E: An exception was received during the call to the method ConnectionFactory.CreateConnection: CompCode: 2, Reason: 2059.
我可以在消息中看到原因,但找不到检索它的方法或属性。