The ActiveMQ InactivityMonitor is an active thread that checks the connection is still active and if it suspects the connection is not functioning correctly, it closes the connection.
Connections are monitored by:
Each connection has two InactivityMonitors associated, one on each end of the connection. The InactivityMonitor expects to receive data on the connection during a specified time period. If normal activemq traffic has not been sent across the connection during that period, it expects to receive a KeepAliveInfo message sent by the InactivityMonitor on the other end of the connection.
Using the default values; if no data has been read from the connection for 30 seconds, the InactivityMonitor assumes there is an issue with the connection. The InactivityMonitor throws an InactivityIOException and shuts down the transport associated with the connection. This results in the following DEBUG logging:
How to specify the max inactivity duration?
The max inactivity duration can be set by specifying the wireFormat.maxInactivityDuration attribute in the connection URL: tcp://localhost:61616?wireFormat.maxInactivityDuration=30000
This attribute is valid for both the broker's transport connector URL and the client side connection URL. Default value is 30000 milliseconds.
What happens if the maxInactivityDuration is set to different values on either side of the same connection?
At startup the InactivityMonitor negotiates the appropriate maxInactivityDuration. The shortest duration is taken as the maxInactivityDuration for the connection.
Can the InactivityMonitor on a connection be disabled?
Setting wireFormat.maxInactivityDuration=0 will disable the InactivityMonitor
What is wireFormat.maxInactivityDurationInitalDelay?
wireFormat.maxInactivityDurationInitalDelay is used to specify the maximum delay before inactivity monitoring is started on the connection. It can be useful if a broker is under load with many connections being created concurrently.
Potential issues to be aware of: