XMS - 如何在网络中断后恢复与WebSphere SIBus的连接

时间:2013-03-08 17:30:37

标签: c# websphere-8

我正在连接到JMS队列。该队列由WebSphere Application Server(版本8.0.0.5)托管,使用SIBus。

我有一个简单的程序来重现一些有问题的行为,它是用C#编写的,并使用XMS(IBM的.NET API)连接到队列。 注意:我从这里获得了IBM.XMS dll:MQC71: WebSphere MQ V7.1 Clients

情景如下:

  1. 运行程序(使用空队列,因此它等待阻塞接收呼叫)
  2. 断开网络(拔掉以太网)
  3. 几分钟后,Receive调用抛出异常
  4. 程序尝试重新连接
  5. 由于网络故障而失败
  6. ...让它循环一下以验证此错误是否一直发生
  7. 恢复网络(插入以太网)
  8. 同样的错误继续发生(使用WireShark验证在connectionFactory.CreateConnection()调用期间没有发生网络流量)
  9. 所以,问题是:为什么CreateConnection()调用什么都不做(不发送任何数据包)但是失败了?

    using IBM.XMS;
    using System;
    
    namespace SimpleTest
    {
        class Program
        {
            static void Main(string[] args)
            {
                while (true)
                {
                    try
                    {
                        string queueURI = "queue://your.details.GoHereDearReader";
                        string providerEndpoint = "1.2.3.4:1234";
                        string targetTransportChain = "InboundBasicMessaging";
                        string busName = "some_bus_name";
    
                        XMSFactoryFactory factoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WPM);
                        IConnectionFactory connectionFactory = factoryFactory.CreateConnectionFactory();
                        connectionFactory.SetStringProperty(XMSC.WPM_PROVIDER_ENDPOINTS, providerEndpoint);
                        connectionFactory.SetStringProperty(XMSC.WPM_TARGET_TRANSPORT_CHAIN, targetTransportChain);
                        connectionFactory.SetStringProperty(XMSC.WPM_BUS_NAME, busName);
    
                        Log("Connecting...");
                        using (var connection = connectionFactory.CreateConnection())
                        {
                            using (var session = connection.CreateSession(false, AcknowledgeMode.AutoAcknowledge))
                            {
                                using (var destination = session.CreateQueue(queueURI))
                                {
                                    destination.SetIntProperty(XMSC.DELIVERY_MODE, XMSC.DELIVERY_NOT_PERSISTENT);
                                    connection.Start();
    
                                    using (IMessageConsumer consumer =  session.CreateConsumer(destination))
                                    {
                                        Log("Receiving...");
                                        IMessage recvMsg = consumer.Receive();
                                        Log("recvMsg:" + recvMsg);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Log(e.ToString());
                    }
                    Log("Sleeping some before consuming more...");
                    System.Threading.Thread.Sleep(10 * 1000);
                }//while
            }//Main
    
            static void Log(string text)
            {
                Console.WriteLine(DateTime.UtcNow.ToString("HH:mm:ss.fff") + "--------------------------  " + text);
            }
    
        }
    }
    

    还有一些输出:

    16:38:19.483--------------------------  Connecting...
    16:38:19.936--------------------------  Receiving...
    16:43:31.952--------------------------  IBM.XMS.XMSException: EXCEPTION_RECEIVED_CWSIA0022
    EXCEPTION_RECEIVED_CWSIA0022.explanation
    EXCEPTION_RECEIVED_CWSIA0022.useraction
       at IBM.XMS.Impl.Connection.Dispose(Boolean disposing)
       at IBM.XMS.Impl.Connection.Dispose()
       at SimpleTest.Program.Main(String[] args) in c:\Users\Administrator\Documents\Visual Studio Projects\TestJMSDequeue\SimpleTest\Program.cs:line 43
    
    Linked Exception : IBM.XMS.SIB.JFAP.JFapConversationClosedException: Exception of type 'IBM.XMS.SIB.JFAP.JFapConversationClosedException' was thrown.
       at IBM.XMS.SIB.JFAP.ConversationImpl.Send(IByteBuffer[] data, JFAPSegmentType segmentType, UInt16 requestNumber, IoPriority priority, Boolean pooledBufferHint, IReceiveListener recvListener, ISendListener sendListener, Object state)
       at IBM.XMS.SIB.JFAP.ConversationImpl.RequestReplyExchange(IByteBuffer[] data, JFAPSegmentType segmentType, UInt16 requestNumber, IoPriority priority, Boolean pooledBufferHint)
       at IBM.XMS.SIB.JFAP.ConversationImpl.RequestReplyExchange(IByteBuffer data, JFAPSegmentType segmentType, UInt16 requestNumber, IoPriority priority, Boolean pooledBufferHint)
       at IBM.XMS.SIB.Comms.Client.JFAPCommunicator.RequestReplyExchange(IByteBuffer data, JFAPSegmentType sendSegType, MessagePriority priority, Boolean canPoolOnReceive)
       at IBM.XMS.SIB.Comms.Client.ConnectionProxy.Close()
       at IBM.XMS.Impl.Connection.Dispose(Boolean disposing)
    16:43:31.952--------------------------  Sleeping some before consuming more...
    16:43:41.967--------------------------  Connecting...
    Exception  : System.InvalidOperationException: UniqueLinkObject no seen on handshake.
       at IBM.XMS.Formats.MFP.SIB.SchemaManager.SendSchemas(ICommsConnection connection, JMFSchema[] schemas)
       at IBM.XMS.Formats.MFP.SIB.JsMsgObject.Encode(Object connection)
    FFDC to xmsffdc8416_2013.03.08T10.43.41.967444.txt
    Exception  : IBM.XMS.Formats.MFP.MessageEncodeFailedException: Exception of type 'IBM.XMS.Formats.MFP.MessageEncodeFailedException' was thrown. ---> System.InvalidOperationException: UniqueLinkObject no seen on handshake.
       at IBM.XMS.Formats.MFP.SIB.SchemaManager.SendSchemas(ICommsConnection connection, JMFSchema[] schemas)
       at IBM.XMS.Formats.MFP.SIB.JsMsgObject.Encode(Object connection)
       --- End of inner exception stack trace ---
       at IBM.XMS.Formats.MFP.SIB.JsMsgObject.Encode(Object connection)
       at IBM.XMS.Formats.MFP.SIB.TrmFirstContactMessageImpl.Encode(Object connection)
       at IBM.XMS.SIB.Trm.ClientBootstrapHandler.Connect(IClientConnection clientConnection)
    FFDC to xmsffdc8416_2013.03.08T10.43.41.983044.txt
    16:43:41.983--------------------------  IBM.XMS.XMSException: EXCEPTION_RECEIVED_CWSIA0241
    EXCEPTION_RECEIVED_CWSIA0241.explanation
    EXCEPTION_RECEIVED_CWSIA0241.useraction
       at IBM.XMS.Impl.ConnectionFactory.CreateConnection(String userName, String password)
       at IBM.XMS.Impl.ConnectionFactory.CreateConnection()
       at SimpleTest.Program.Main(String[] args) in c:\Users\Administrator\Documents\Visual Studio Projects\TestJMSDequeue\SimpleTest\Program.cs:line 26
    
    Linked Exception : IBM.XMS.Core.SIResourceException: CWSIT0006E: It is not possible to connect to bus your_bus_name_here because the following bootstrap servers could not be contacted  1.2.3.4:1234:BootstrapBasicMessaging and the following bootstrap servers returned an error condition . See previous messages for the reason for each bootstrap server failure.
    The client cannot connect to the bus. This situation may be due to configuration problems, network problems or it may be that none of the required bootstrap servers or messaging engines are currently available.
    Ensure that the network is working correctly and that the required bootstrap servers and messaging engines are available. ---> IBM.XMS.Core.SIConnectionLostException: Exception of type 'IBM.XMS.Core.SIConnectionLostException' was thrown.
       at IBM.XMS.SIB.Comms.Client.ClientSideConnection.Connect(ConnectionProperties cp, IClientComponentHandshake cch, SICoreConnectionProperties siProps)
       at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactoryImpl.Bootstrap(Credentials credentials, SICoreConnectionProperties connectionProperties, ClientAttachProperties cap)
       --- End of inner exception stack trace ---
       at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactoryImpl.Bootstrap(Credentials credentials, SICoreConnectionProperties connectionProperties, ClientAttachProperties cap)
       at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactoryImpl.CreateConnection(Credentials credentials, SICoreConnectionProperties connectionProperties)
       at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactory.CreateConnection(String username, String password, SICoreConnectionProperties connectionProperties)
       at IBM.XMS.Impl.ConnectionFactory.CreateConnection(String userName, String password)
    16:43:41.983--------------------------  Sleeping some before consuming more...
    16:43:51.998--------------------------  Connecting...
    Exception  : System.InvalidOperationException: UniqueLinkObject no seen on handshake.
       at IBM.XMS.Formats.MFP.SIB.SchemaManager.SendSchemas(ICommsConnection connection, JMFSchema[] schemas)
       at IBM.XMS.Formats.MFP.SIB.JsMsgObject.Encode(Object connection)
    FFDC to xmsffdc8416_2013.03.08T10.43.51.998262.txt
    Exception  : IBM.XMS.Formats.MFP.MessageEncodeFailedException: Exception of type 'IBM.XMS.Formats.MFP.MessageEncodeFailedException' was thrown. ---> System.InvalidOperationException: UniqueLinkObject no seen on handshake.
       at IBM.XMS.Formats.MFP.SIB.SchemaManager.SendSchemas(ICommsConnection connection, JMFSchema[] schemas)
       at IBM.XMS.Formats.MFP.SIB.JsMsgObject.Encode(Object connection)
       --- End of inner exception stack trace ---
       at IBM.XMS.Formats.MFP.SIB.JsMsgObject.Encode(Object connection)
       at IBM.XMS.Formats.MFP.SIB.TrmFirstContactMessageImpl.Encode(Object connection)
       at IBM.XMS.SIB.Trm.ClientBootstrapHandler.Connect(IClientConnection clientConnection)
    FFDC to xmsffdc8416_2013.03.08T10.43.51.998262.txt
    16:43:51.998--------------------------  IBM.XMS.XMSException: EXCEPTION_RECEIVED_CWSIA0241
    EXCEPTION_RECEIVED_CWSIA0241.explanation
    EXCEPTION_RECEIVED_CWSIA0241.useraction
       at IBM.XMS.Impl.ConnectionFactory.CreateConnection(String userName, String password)
       at IBM.XMS.Impl.ConnectionFactory.CreateConnection()
       at SimpleTest.Program.Main(String[] args) in c:\Users\Administrator\Documents\Visual Studio Projects\TestJMSDequeue\SimpleTest\Program.cs:line 26
    
    Linked Exception : IBM.XMS.Core.SIResourceException: CWSIT0006E: It is not possible to connect to bus your_bus_name_here because the following bootstrap servers could not be contacted  1.2.3.4:1234:BootstrapBasicMessaging and the following bootstrap servers returned an error condition . See previous messages for the reason for each bootstrap server failure.
    The client cannot connect to the bus. This situation may be due to configuration problems, network problems or it may be that none of the required bootstrap servers or messaging engines are currently available.
    Ensure that the network is working correctly and that the required bootstrap servers and messaging engines are available. ---> IBM.XMS.Core.SIConnectionLostException: Exception of type 'IBM.XMS.Core.SIConnectionLostException' was thrown.
       at IBM.XMS.SIB.Comms.Client.ClientSideConnection.Connect(ConnectionProperties cp, IClientComponentHandshake cch, SICoreConnectionProperties siProps)
       at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactoryImpl.Bootstrap(Credentials credentials, SICoreConnectionProperties connectionProperties, ClientAttachProperties cap)
       --- End of inner exception stack trace ---
       at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactoryImpl.Bootstrap(Credentials credentials, SICoreConnectionProperties connectionProperties, ClientAttachProperties cap)
       at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactoryImpl.CreateConnection(Credentials credentials, SICoreConnectionProperties connectionProperties)
       at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactory.CreateConnection(String username, String password, SICoreConnectionProperties connectionProperties)
       at IBM.XMS.Impl.ConnectionFactory.CreateConnection(String userName, String password)
    16:43:51.998--------------------------  Sleeping some before consuming more...
    16:44:02.013--------------------------  Connecting...
    Exception  : System.InvalidOperationException: UniqueLinkObject no seen on handshake.
       at IBM.XMS.Formats.MFP.SIB.SchemaManager.SendSchemas(ICommsConnection connection, JMFSchema[] schemas)
       at IBM.XMS.Formats.MFP.SIB.JsMsgObject.Encode(Object connection)
    FFDC to xmsffdc8416_2013.03.08T10.44.02.013479.txt
    Exception  : IBM.XMS.Formats.MFP.MessageEncodeFailedException: Exception of type 'IBM.XMS.Formats.MFP.MessageEncodeFailedException' was thrown. ---> System.InvalidOperationException: UniqueLinkObject no seen on handshake.
       at IBM.XMS.Formats.MFP.SIB.SchemaManager.SendSchemas(ICommsConnection connection, JMFSchema[] schemas)
       at IBM.XMS.Formats.MFP.SIB.JsMsgObject.Encode(Object connection)
       --- End of inner exception stack trace ---
       at IBM.XMS.Formats.MFP.SIB.JsMsgObject.Encode(Object connection)
       at IBM.XMS.Formats.MFP.SIB.TrmFirstContactMessageImpl.Encode(Object connection)
       at IBM.XMS.SIB.Trm.ClientBootstrapHandler.Connect(IClientConnection clientConnection)
    FFDC to xmsffdc8416_2013.03.08T10.44.02.013479.txt
    16:44:02.013--------------------------  IBM.XMS.XMSException: EXCEPTION_RECEIVED_CWSIA0241
    EXCEPTION_RECEIVED_CWSIA0241.explanation
    EXCEPTION_RECEIVED_CWSIA0241.useraction
       at IBM.XMS.Impl.ConnectionFactory.CreateConnection(String userName, String password)
       at IBM.XMS.Impl.ConnectionFactory.CreateConnection()
       at SimpleTest.Program.Main(String[] args) in c:\Users\Administrator\Documents\Visual Studio Projects\TestJMSDequeue\SimpleTest\Program.cs:line 26
    
    Linked Exception : IBM.XMS.Core.SIResourceException: CWSIT0006E: It is not possible to connect to bus your_bus_name_here because the following bootstrap servers could not be contacted  1.2.3.4:1234:BootstrapBasicMessaging and the following bootstrap servers returned an error condition . See previous messages for the reason for each bootstrap server failure.
    The client cannot connect to the bus. This situation may be due to configuration problems, network problems or it may be that none of the required bootstrap servers or messaging engines are currently available.
    Ensure that the network is working correctly and that the required bootstrap servers and messaging engines are available. ---> IBM.XMS.Core.SIConnectionLostException: Exception of type 'IBM.XMS.Core.SIConnectionLostException' was thrown.
       at IBM.XMS.SIB.Comms.Client.ClientSideConnection.Connect(ConnectionProperties cp, IClientComponentHandshake cch, SICoreConnectionProperties siProps)
       at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactoryImpl.Bootstrap(Credentials credentials, SICoreConnectionProperties connectionProperties, ClientAttachProperties cap)
       --- End of inner exception stack trace ---
       at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactoryImpl.Bootstrap(Credentials credentials, SICoreConnectionProperties connectionProperties, ClientAttachProperties cap)
       at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactoryImpl.CreateConnection(Credentials credentials, SICoreConnectionProperties connectionProperties)
       at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactory.CreateConnection(String username, String password, SICoreConnectionProperties connectionProperties)
       at IBM.XMS.Impl.ConnectionFactory.CreateConnection(String userName, String password)
    16:44:02.013--------------------------  Sleeping some before consuming more...
    

    请注意,在上面的输出中,我在“接收...”后不久就拔掉了网络,并在16:43:52重新插入网络,但之后错误仍在继续,直到我杀死了该程序。

2 个答案:

答案 0 :(得分:0)

当网络再次可用时,它读起来就像ConnectionFactory没有正确地重置它的状态。

我已经在参考手册中搜索了工厂的任何重置功能提示 - 但是没有找到。 不过我会尝试这样做:将GetInstance(...)createConnectionFactory()移出循环,以及SetStringProperty()行。

如果这不起作用,我无法理解为什么你的客户不会工作。 您是否考虑过这是服务器的问题?你拔掉哪根以太网线?连接到客户端或服务器的那个?如果是服务器,拔下客户端电缆时是否会出现同样的问题? 如果你重新启动程序,它会工作吗?

答案 1 :(得分:0)

我知道这是一篇旧帖子,但也许它仍然有用。

创建65.535个连接后收到此错误。如果关闭连接/处置对象并不重要。

我看到以下解决方案:

1。)您可以创建一次连接,并为队列上的所有操作重用连接,直到连接中断。然后你必须重新连接。 (是的,这很糟糕,反对常见的模式。我不建议这样做)

2.。)版本8.0.0.6有一个错误修正。 编辑:APAR#(IJ01244) 我还不知道它什么时候会包含在未来版本中。 我猜您可以联系IBM支持人员并参考此PMR ID以获取IBM.XMS.SIB.dll的更新版本

希望这有帮助。