mirror of
https://github.com/apache/activemq-artemis.git
synced 2025-03-08 10:19:30 +00:00
ARTEMIS-640 Allow config of cxn TTL check interval
Add connection-ttl-check-interval configuration attribute to allow control of how frequently connection TTL checks are performed.
This commit is contained in:
parent
7bf62ff660
commit
dc76e2a6a0
@ -423,6 +423,9 @@ public final class ActiveMQDefaultConfiguration {
|
||||
// Default large messages table name, used with Database storage type
|
||||
private static final String DEFAULT_LARGE_MESSAGES_TABLE_NAME = "LARGE_MESSAGES";
|
||||
|
||||
// Default period to wait between connection TTL checks
|
||||
public static final long DEFAULT_CONNECTION_TTL_CHECK_INTERVAL = 2000;
|
||||
|
||||
/**
|
||||
* If true then the ActiveMQ Artemis Server will make use of any Protocol Managers that are in available on the classpath. If false then only the core protocol will be available, unless in Embedded mode where users can inject their own Protocol Managers.
|
||||
*/
|
||||
@ -1130,4 +1133,8 @@ public final class ActiveMQDefaultConfiguration {
|
||||
public static String getDefaultLargeMessagesTableName() {
|
||||
return DEFAULT_LARGE_MESSAGES_TABLE_NAME;
|
||||
}
|
||||
|
||||
public static long getDefaultConnectionTtlCheckInterval() {
|
||||
return DEFAULT_CONNECTION_TTL_CHECK_INTERVAL;
|
||||
}
|
||||
}
|
||||
|
@ -955,4 +955,8 @@ public interface Configuration {
|
||||
/** It will return all the connectors in a toString manner for debug purposes. */
|
||||
String debugConnectors();
|
||||
|
||||
Configuration setConnectionTtlCheckInterval(long connectionTtlCheckInterval);
|
||||
|
||||
long getConnectionTtlCheckInterval();
|
||||
|
||||
}
|
||||
|
@ -239,6 +239,8 @@ public class ConfigurationImpl implements Configuration, Serializable {
|
||||
|
||||
protected boolean populateValidatedUser = ActiveMQDefaultConfiguration.isDefaultPopulateValidatedUser();
|
||||
|
||||
private long connectionTtlCheckInterval = ActiveMQDefaultConfiguration.getDefaultConnectionTtlCheckInterval();
|
||||
|
||||
/**
|
||||
* Parent folder for all data folders.
|
||||
*/
|
||||
@ -1365,6 +1367,17 @@ public class ConfigurationImpl implements Configuration, Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getConnectionTtlCheckInterval() {
|
||||
return connectionTtlCheckInterval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationImpl setConnectionTtlCheckInterval(long connectionTtlCheckInterval) {
|
||||
this.connectionTtlCheckInterval = connectionTtlCheckInterval;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
@ -1440,6 +1453,7 @@ public class ConfigurationImpl implements Configuration, Serializable {
|
||||
result = prime * result + (wildcardRoutingEnabled ? 1231 : 1237);
|
||||
result = prime * result + (resolveProtocols ? 1231 : 1237);
|
||||
result = prime * result + (int) (journalLockAcquisitionTimeout ^ (journalLockAcquisitionTimeout >>> 32));
|
||||
result = prime * result + (int) (connectionTtlCheckInterval ^ (connectionTtlCheckInterval >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1692,6 +1706,8 @@ public class ConfigurationImpl implements Configuration, Serializable {
|
||||
return false;
|
||||
if (journalLockAcquisitionTimeout != other.journalLockAcquisitionTimeout)
|
||||
return false;
|
||||
if (connectionTtlCheckInterval != other.connectionTtlCheckInterval)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -278,6 +278,8 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
|
||||
|
||||
config.setPopulateValidatedUser(getBoolean(e, "populate-validated-user", config.isPopulateValidatedUser()));
|
||||
|
||||
config.setConnectionTtlCheckInterval(getLong(e, "connection-ttl-check-interval", config.getConnectionTtlCheckInterval(), Validators.GT_ZERO));
|
||||
|
||||
// parsing cluster password
|
||||
String passwordText = getString(e, "cluster-password", null, Validators.NO_CHECK);
|
||||
|
||||
|
@ -238,6 +238,14 @@
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="connection-ttl-check-interval" type="xsd:long" default="2000" maxOccurs="1" minOccurs="0">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
how often (in ms) to check connections for ttl violation
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="async-connection-execution-enabled" type="xsd:boolean" default="true" maxOccurs="1"
|
||||
minOccurs="0">
|
||||
<xsd:annotation>
|
||||
|
@ -103,6 +103,7 @@ public class FileConfigurationTest extends ConfigurationImplTest {
|
||||
Assert.assertEquals(true, conf.isGracefulShutdownEnabled());
|
||||
Assert.assertEquals(12345, conf.getGracefulShutdownTimeout());
|
||||
Assert.assertEquals(true, conf.isPopulateValidatedUser());
|
||||
Assert.assertEquals(98765, conf.getConnectionTtlCheckInterval());
|
||||
|
||||
Assert.assertEquals("largemessagesdir", conf.getLargeMessagesDirectory());
|
||||
Assert.assertEquals(95, conf.getMemoryWarningThreshold());
|
||||
|
@ -51,6 +51,7 @@
|
||||
<id-cache-size>127</id-cache-size>
|
||||
<persist-id-cache>true</persist-id-cache>
|
||||
<populate-validated-user>true</populate-validated-user>
|
||||
<connection-ttl-check-interval>98765</connection-ttl-check-interval>
|
||||
<remoting-incoming-interceptors>
|
||||
<class-name>org.apache.activemq.artemis.tests.unit.core.config.impl.TestInterceptor1</class-name>
|
||||
<class-name>org.apache.activemq.artemis.tests.unit.core.config.impl.TestInterceptor2</class-name>
|
||||
|
@ -35,6 +35,7 @@ Name | Description
|
||||
[cluster-password](clusters.md "Clusters") | Cluster password. It applies to all cluster configurations.
|
||||
[cluster-user](clusters.md "Clusters") | Cluster username. It applies to all cluster configurations.
|
||||
[connection-ttl-override](connection-ttl.md) | if set, this will override how long (in ms) to keep a connection alive without receiving a ping. -1 disables this setting. Default -1
|
||||
[connection-ttl-check-period](connection-ttl.md) | how often (in ms) to check connections for ttl violation. Default 2000
|
||||
[connectors.connector](configuring-transports.md "Understanding Connectors") | The URL for the connector. This is a list
|
||||
[create-bindings-dir](persistence.md "Configuring the bindings journal") | true means that the server will create the bindings directory on start up. Default=true
|
||||
[create-journal-dir](persistence.md) | true means that the journal directory will be created. Default=true
|
||||
|
@ -114,6 +114,11 @@ server side. This can be done by specifying the
|
||||
The default value for `connection-ttl-override` is `-1` which means "do
|
||||
not override" (i.e. let clients use their own values).
|
||||
|
||||
The logic to check connections for TTL violations runs periodically on
|
||||
the broker. By default, the checks are done every 2,000 milliseconds.
|
||||
However, this can be changed if necessary by using the
|
||||
`connection-ttl-check-interval` attribute.
|
||||
|
||||
## Closing core sessions or JMS connections that you have failed to close
|
||||
|
||||
As previously discussed, it's important that all core client sessions
|
||||
|
@ -37,7 +37,6 @@ import org.apache.activemq.artemis.core.protocol.core.Packet;
|
||||
import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
|
||||
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionMessage;
|
||||
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionResponseMessage;
|
||||
import org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.core.version.impl.VersionImpl;
|
||||
@ -162,7 +161,7 @@ public class IncompatibleVersionTest extends ActiveMQTestBase {
|
||||
fail("Invalid Exception type:" + e.getType());
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() < start + 3 * RemotingServiceImpl.CONNECTION_TTL_CHECK_INTERVAL) {
|
||||
while (System.currentTimeMillis() < start + 3 * server.getConfiguration().getConnectionTtlCheckInterval()) {
|
||||
if (server.getConnectionCount() == 0) {
|
||||
break;
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ import org.apache.activemq.artemis.core.protocol.core.Packet;
|
||||
import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
|
||||
import org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImpl;
|
||||
import org.apache.activemq.artemis.core.remoting.CloseListener;
|
||||
import org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl;
|
||||
import org.apache.activemq.artemis.core.server.ServerSession;
|
||||
import org.apache.activemq.artemis.core.server.impl.ServerSessionImpl;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
|
||||
@ -475,7 +474,7 @@ public class TemporaryQueueTest extends SingleServerTestBase {
|
||||
session = sf.createSession(false, true, true);
|
||||
|
||||
session.createTemporaryQueue(address, queue);
|
||||
assertTrue("server has not received any ping from the client", pingOnServerLatch.await(2 * RemotingServiceImpl.CONNECTION_TTL_CHECK_INTERVAL, TimeUnit.MILLISECONDS));
|
||||
assertTrue("server has not received any ping from the client", pingOnServerLatch.await(2 * server.getConfiguration().getConnectionTtlCheckInterval(), TimeUnit.MILLISECONDS));
|
||||
assertEquals(1, server.getConnectionCount());
|
||||
|
||||
RemotingConnection remotingConnection = server.getRemotingService().getConnections().iterator().next();
|
||||
@ -490,7 +489,7 @@ public class TemporaryQueueTest extends SingleServerTestBase {
|
||||
((ClientSessionInternal) session).getConnection().fail(new ActiveMQInternalErrorException("simulate a client failure"));
|
||||
|
||||
// let some time for the server to clean the connections
|
||||
assertTrue("server has not closed the connection", serverCloseLatch.await(2 * RemotingServiceImpl.CONNECTION_TTL_CHECK_INTERVAL + 2 * TemporaryQueueTest.CONNECTION_TTL, TimeUnit.MILLISECONDS));
|
||||
assertTrue("server has not closed the connection", serverCloseLatch.await(2 * server.getConfiguration().getConnectionTtlCheckInterval() + 2 * TemporaryQueueTest.CONNECTION_TTL, TimeUnit.MILLISECONDS));
|
||||
|
||||
// The next getCount will be asynchronously done at the end of failure. We will wait some time until it has reached there.
|
||||
for (long timeout = System.currentTimeMillis() + 5000; timeout > System.currentTimeMillis() && server.getConnectionCount() > 0; ) {
|
||||
|
@ -31,7 +31,6 @@ import org.apache.activemq.artemis.core.protocol.core.Packet;
|
||||
import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
|
||||
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.Ping;
|
||||
import org.apache.activemq.artemis.core.remoting.CloseListener;
|
||||
import org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
|
||||
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
|
||||
@ -397,7 +396,7 @@ public class PingTest extends ActiveMQTestBase {
|
||||
Assert.assertTrue(clientLatch.await(8 * PingTest.CLIENT_FAILURE_CHECK_PERIOD, TimeUnit.MILLISECONDS));
|
||||
|
||||
// Server connection will be closed too, when client closes client side connection after failure is detected
|
||||
Assert.assertTrue(serverLatch.await(2 * RemotingServiceImpl.CONNECTION_TTL_CHECK_INTERVAL, TimeUnit.MILLISECONDS));
|
||||
Assert.assertTrue(serverLatch.await(2 * server.getConfiguration().getConnectionTtlCheckInterval(), TimeUnit.MILLISECONDS));
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
while (true) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user