ARTEMIS-1581 fix handshake-timeout property configurability
This commit is contained in:
parent
719adab1ee
commit
c05ec28de2
|
@ -315,6 +315,7 @@ public class TransportConstants {
|
|||
allowableAcceptorKeys.add(ActiveMQDefaultConfiguration.getPropPasswordCodec());
|
||||
allowableAcceptorKeys.add(TransportConstants.BACKLOG_PROP_NAME);
|
||||
allowableAcceptorKeys.add(TransportConstants.CRL_PATH_PROP_NAME);
|
||||
allowableAcceptorKeys.add(TransportConstants.HANDSHAKE_TIMEOUT);
|
||||
|
||||
ALLOWABLE_ACCEPTOR_KEYS = Collections.unmodifiableSet(allowableAcceptorKeys);
|
||||
|
||||
|
|
|
@ -21,13 +21,18 @@ import javax.jms.ConnectionFactory;
|
|||
import javax.jms.Queue;
|
||||
import javax.jms.Topic;
|
||||
import javax.naming.Context;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration;
|
||||
|
@ -38,9 +43,13 @@ import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
|
|||
import org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.TopicConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.junit.Wait;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.utils.RandomUtil;
|
||||
import org.apache.activemq.transport.netty.NettyTransport;
|
||||
import org.apache.activemq.transport.netty.NettyTransportFactory;
|
||||
import org.apache.activemq.transport.netty.NettyTransportListener;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -97,4 +106,46 @@ public class JMSConfigurationTest extends ActiveMQTestBase {
|
|||
|
||||
server.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandshakeTimeoutWithValueSet() throws Exception {
|
||||
final int HANDSHAKE_TIMEOUT = 5;
|
||||
|
||||
ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(createDefaultConfig(false)
|
||||
.clearAcceptorConfigurations()
|
||||
.addAcceptorConfiguration("netty", "tcp://localhost:61616?handshake-timeout=5")));
|
||||
server.start();
|
||||
|
||||
TransportConfiguration tc = server.getConfiguration().getAcceptorConfigurations().iterator().next();
|
||||
String host = (String) tc.getParams().get(TransportConstants.HOST_PROP_NAME);
|
||||
String port = (String) tc.getParams().get(TransportConstants.PORT_PROP_NAME);
|
||||
Object handshakeTimeout = tc.getParams().get(TransportConstants.HANDSHAKE_TIMEOUT);
|
||||
assertNotNull(handshakeTimeout);
|
||||
assertEquals(HANDSHAKE_TIMEOUT, Integer.parseInt(handshakeTimeout.toString()));
|
||||
|
||||
NettyTransport transport = NettyTransportFactory.createTransport(new URI("tcp://" + host + ":" + port));
|
||||
transport.setTransportListener(new NettyTransportListener() {
|
||||
@Override
|
||||
public void onData(ByteBuf incoming) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransportClosed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransportError(Throwable cause) {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
try {
|
||||
transport.connect();
|
||||
assertTrue("Connection should be closed now", Wait.waitFor(() -> !transport.isConnected(), TimeUnit.SECONDS.toMillis(HANDSHAKE_TIMEOUT + 1)));
|
||||
} finally {
|
||||
transport.close();
|
||||
server.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue