背景:
C# WPF 应用程序通过 ActiveMQ/JSON 与在 linux 上运行的 JAVA 服务器交谈
总共 5 个连接实例:
队列:2
主题:3(1 个生产者,2 个消费者)
问题:
在大量使用情况下(在不到 500 毫秒的时间内发送/接收大约 200 条消息的吞吐量,内存工作设置在 1-1.2 GB 左右),抛出“已建立的连接被主机中的软件中止”。
样本堆栈:
Apache.NMS.NMSException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
at System.IO.BinaryReader.ReadInt32()
at Apache.NMS.Util.EndianBinaryReader.ReadInt32()
at Apache.NMS.ActiveMQ.OpenWire.OpenWireFormat.Unmarshal(BinaryReader dis)
at Apache.NMS.ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop()
到目前为止尝试过:
- 关闭不活动监控以减少 5 个连接的流量。主要是因为应用程序有自己的心跳实现。
- 将 ConnectionFactory.OptimizeAcknowledge 设置为 true 以批量确认