2013-12-12 184 views
0

我目前正面臨一個問題,我正在接收發生的錯誤I/O錯誤。我不知道如何確定發生錯誤的位置。當我從隊列中獲取消息隊列時發生這種情況。以下是錯誤的堆棧跟蹤。從Websphere獲取消息隊列時發生I/O錯誤MQ

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

這是一個Java或C#應用程序?如果是Java,你應該這樣做:

result = mqMessage.ReadString(mqMessage.getMessageLength());