activeMQ uses the disconnection and reconnection mechanism to report an error

[Phenomena]: ActiveMQ integrates spring without the disconnection and reconnection mechanism, and there may be a problem of lost messages. If the disconnection and reconnection mechanism is used, a socket exception will be reported.

WARN  10-31 15:27:54 Transport (tcp:///172.20.0.125:61616@52935) failed, attempting to automatically reconnect  (FailoverTransport.java:267) 

java.net.SocketException: Software caused connection abort: recv failed

at java.net.SocketInputStream.socketRead0(Native Method)

at java.net.SocketInputStream.read(SocketInputStream.java:173)

at java.net.SocketInputStream.read(SocketInputStream.java:122)

at org.apache.activemq.transport.tcp.TcpBufferedInputStream.fill(TcpBufferedInputStream.java:50)

at org.apache.activemq.transport.tcp.TcpTransport$2.fill(TcpTransport.java:609)

at org.apache.activemq.transport.tcp.TcpBufferedInputStream.read(TcpBufferedInputStream.java:58)

at org.apache.activemq.transport.tcp.TcpTransport$2.read(TcpTransport.java:594)

at java.io.DataInputStream.readInt(DataInputStream.java:387)

at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:258)

at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:221)

at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:213)

at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:196)

at java.lang.Thread.run(Thread.java:745)

【Cause Analysis】:

       This has to start with Java 's java.NET .SocketException exception. Simply put, it is when the network sender sends a bunch of data and then calls close to close the connection. These sent data are all in the receiver's cache. If the receiver calls the read method, the data can still be read from the cache, even though the other party has closed the connection. But when the receiver tries to send data, because the connection is closed at this time, an exception will occur, which is well understood. However, it should be noted that when a SocketException occurs, the data in the original buffer area is also invalid. At this time, the receiver calls the read method again to read the data in the buffer, and the error Software caused connection abort: recv failed will be reported.

       Through packet capture, ActiveMQ will send a heartbeat packet every 10 seconds. This heartbeat packet is sent by the server to the client to determine whether the client is dead or not. If you have read the first article above, you will know that non-persistent messages will be written to the file when they accumulate to a certain extent. This writing process will block all actions, and it will last for 20 to 30 seconds, and as the memory increases and increase. When the client calls connection.close() after sending the message, it will expect the server's answer to close the connection. If there is no answer for more than 15 seconds, it will directly call the close of the socket layer to close the tcp connection. At this time, the message sent by the client is still waiting to be processed in the server's cache, but due to the setting of the server's heartbeat packet, a java.Net.SocketException exception occurs , the data in the cache is invalid, and all unprocessed messages are lost.

【solution】:

Since I can't find a good way to solve it, and because the exception reported by the system is a warning type exception, it does not affect the use of the function for the time being. Therefore, adding the following code to log4j.xml will not print all such error levels. 's log.

<category name="org.apache.activemq.transport.failover.FailoverTransport">

<priority value="error" />

</category>

 

 

 

 

 

 

 

 

 

 

 

 

 

Reward the sharer

          If this sharing has helped you, then reward me. If you have money, you can support a money field (support Alipay and WeChat donations), but if you don’t have money, you can support a personal field. With everyone’s support, we will be more motivated and will do better, thank you.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326467542&siteId=291194637