2014-01-28 29 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个错误。 –