我正在连接到 JMS 队列。该队列由 WebSphere Application Server(版本 8.0.0.5)使用 SIBus 托管。
我有一个简单的程序来重现一些有问题的行为,它是用 C# 编写的,并使用 XMS(IBM 的 .NET API)连接到队列。注意:我从这里获得了 IBM.XMS dll:MQC71: WebSphere MQ V7.1 Clients
场景是这样的:
- 运行程序(使用一个空队列,因此它等待阻塞的接收调用)
- 断开网络(拔下以太网)
- 几分钟后,Receive 调用引发异常
- 程序尝试重新连接
- 由于网络关闭而失败
- ...让它循环一下以验证此错误是否不断发生
- 恢复网络(插入以太网)
- 继续发生相同的错误(使用 WireShark 验证在 connectionFactory.CreateConnection() 调用期间没有发生网络流量)
所以,问题是:为什么 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 再次插入,但在那之后错误继续存在,直到我终止了程序。