我目前正面临一个问题,我正在收到错误I / O错误。我不知道如何确定错误发生的位置。当我从队列中获取消息队列时,就会发生这种情况。下面是错误的堆栈跟踪。
StackTrace: at AlertTrigger.Data.ServiceAgents.WebSphereAgent.GetMessageQueue(String queueManagerName, String queueName)
at AlertTrigger.Business.AlertTriggerComponent.QueueListener()
以下是GetMessageQueue的代码:
public string GetMessageQueue(string queueManagerName, string queueName)
{
MQQueueManager mqQueueManager;
MQQueue storeQueue;
string result = string.Empty;
try
{
MQMessage mqMessage = new MQMessage();
MQGetMessageOptions mqGetMessageOption = new MQGetMessageOptions();
mqGetMessageOption.Options = MQC.MQGMO_WAIT;
mqGetMessageOption.WaitInterval = 15000;
mqQueueManager = new MQQueueManager(queueManagerName);
storeQueue = mqQueueManager.AccessQueue(queueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
storeQueue.Get(mqMessage, mqGetMessageOption);
result = mqMessage.ReadString(mqMessage.DataLength);
}
catch (MQException MQEx)
{
// Close request Queue if still opened
if (storeQueue != null && storeQueue.OpenStatus)
storeQueue.Close();
// Close Queue manager if still opened
if (mqQueueManager != null && mqQueueManager.OpenStatus)
mqQueueManager.Close();
throw new MQAdapterException(MQEx.Reason.ToString());
//throw new MQAdapterException("Error Code: " + MQAdapterErrorReasons.GetMQFailureReasonErrorCode(MQEx.Reason));
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
// Close request Queue if still opened
if (storeQueue != null && storeQueue.OpenStatus)
storeQueue.Close();
// Close Queue manager if still opened
if (mqQueueManager != null && mqQueueManager.OpenStatus)
mqQueueManager.Close();
}
return result;
}
我希望你能帮助我,因为我对WebSphere MQ不熟悉。
答案 0 :(得分:0)
这是Java还是C#应用程序?如果是Java,你应该这样做:
result = mqMessage.ReadString(mqMessage.getMessageLength());