2014-01-28 54 views
0

下面的示例程序應該定期啓動,並應儘快處理隊列(在另一臺計算機上)的所有消息,然後停止。每個消息都應該在單獨的分佈式事務中處理,因爲處理過程還需要訪問和更改多個數據庫。Websphere MQ 7.5.0.2在XA事務中接收消息的間歇性錯誤

託管模式似乎太慢,因爲它每3秒處理一條消息。

非託管模式具有可接受的性能,但我遇到了2個問題。

1)在程序結束時,服務器的事件日誌中包含數百個錯誤消息,所有報告相同的錯誤:

28/01/2014 15:20:49 - Process(8604.48) User(<<username>>) Program(amqrmppa.exe) Host(<<server machinename>>) Installation(Server) VRMF(7.5.0.2) QMgr(<<queuemanager name>>) 

Error on receive from host <<client machinename>> (<<client ip>>). 

An error occurred receiving data from <<client machinename>> (<<client ip>>) over TCP/IP. This may be due to a communications failure. 

The return code from the TCP/IP recv() call was 10054 (X'2746'). Record these values and tell the systems administrator. 

2)消息的數量有限的運行程序對一個隊列變細(除上述問題),但是卻處理幾百消息(500+)之後突然出現以下異常崩潰: MQException: MQRC_UOW_ENLISTMENT_ERROR, CompCode 2, Reason: 2354

第二個問題可能與第一,但我不代碼看不到任何錯誤。所有MQ對象都正確斷開連接,關閉和處置。

所有幫助是值得歡迎...

using System; 
using System.Collections; 
using System.Text; 
using System.Transactions; 
using IBM.WMQ; 

namespace WMQTest 
{ 
    internal class Program 
    { 
     private const string HostName = "TST010"; 
     private const int Port = 5021; 
     private const string ChannelName = "CL_QMSTST010"; 
     private const string QueueManagerName = "QMSTST010"; 
     private const string QueueName = "SD.TRANSX.ARCHIVE"; 

     private static readonly MQGetMessageOptions GetMessageOptions = new MQGetMessageOptions 
     { 
      Options = MQC.MQGMO_WAIT + MQC.MQGMO_SYNCPOINT, 
      WaitInterval = 20000 
     }; 

     private static readonly TransactionOptions TransactionOptions = new TransactionOptions { Timeout = TransactionManager.DefaultTimeout, IsolationLevel = IsolationLevel.Serializable }; 

     private static void Main() 
     { 
      try 
      { 
       Console.WriteLine("Use managed mode?"); 
       var key = Console.ReadKey(true); 
       bool managedMode = key.KeyChar == 'y' || key.KeyChar == 'Y'; 
       var properties = new Hashtable 
        { 
         {MQC.HOST_NAME_PROPERTY, HostName}, 
         {MQC.PORT_PROPERTY, Port}, 
         {MQC.CHANNEL_PROPERTY, ChannelName}, 
         { 
          MQC.TRANSPORT_PROPERTY, 
          managedMode ? MQC.TRANSPORT_MQSERIES_MANAGED : MQC.TRANSPORT_MQSERIES_XACLIENT 
         } 
        }; 
       while (true) 
       { 
        //starting a transaction scope    
        using (var transaction = managedMode 
               ? new TransactionScope() 
               : new TransactionScope(TransactionScopeOption.Required, 
                     TransactionOptions, 
                     EnterpriseServicesInteropOption.Full)) 
        { 
         using (var queueManager = new MQQueueManager(QueueManagerName, properties)) 
         { 
          using (
           MQQueue queue = queueManager.AccessQueue(QueueName, 
                     MQC.MQOO_INPUT_AS_Q_DEF + 
                     MQC.MQOO_FAIL_IF_QUIESCING)) 
          { 
           var message = new MQMessage(); 
           try 
           { 
            queue.Get(message, GetMessageOptions); 
           } 
           catch (MQException ex) 
           { 
            if (ex.CompCode != 2 || ex.ReasonCode != MQC.MQRC_NO_MSG_AVAILABLE) 
            { 
             throw; 
            } 
            //No message available, stop 
            break; 
           } 
           //TODO: DO SOME INTERESTING DATABASE STUFF HERE 
           Console.WriteLine(Encoding.ASCII.GetString(message.MessageId)); 
           // 
           message.ClearMessage(); 
           queue.Close(); 
          } 
          queueManager.Disconnect(); 
         } 
         transaction.Complete(); 
        } 
       } 
      } 
      catch (Exception ex) 
      { 
       Console.WriteLine("EXCEPTION OCCURRED"); 
       Console.WriteLine("=================="); 
       Console.WriteLine(ex); 
      } 
     } 
    } 
} 

回答

1

有在XA地區提供一些修正。這些全部用於管理模式。您可能希望聯繫IBM獲取這些修復程序並應用並查看是否有幫助。

http://www-01.ibm.com/support/docview.wss?rs=171&uid=swg1IC92296

http://www-01.ibm.com/support/docview.wss?rs=171&uid=swg1IC92931

http://www-01.ibm.com/support/docview.wss?rs=171&uid=swg1IC92932

+0

感謝。我們已經爲XMS.NET的類似問題創建了PMR。我們將看到什麼出來... –

+0

我剛剛測試了上面的程序對最近發佈的v7.5 Fixpack 3。這有你提到的所有修補程序。非託管模式仍然存在所描述的問題。託管模式似乎運行正常,但在每次運行後WMQ服務器的事件日誌中仍會留下1個錯誤。 –

相關問題