Search in sources :

Example 1 with HornetQClientProtocolManagerFactory

use of org.apache.activemq.artemis.core.protocol.hornetq.client.HornetQClientProtocolManagerFactory in project activemq-artemis by apache.

the class HQClientProtocolManagerTest method testNoCheckFailoverMessage.

@Test
public void testNoCheckFailoverMessage() throws Exception {
    final int pingPeriod = 1000;
    ActiveMQServer server = createServer(false, true);
    server.start();
    ClientSessionInternal session = null;
    try {
        ServerLocator locator = createFactory(true).setClientFailureCheckPeriod(pingPeriod).setRetryInterval(500).setRetryIntervalMultiplier(1d).setReconnectAttempts(-1).setConfirmationWindowSize(1024 * 1024);
        locator.setProtocolManagerFactory(new HornetQClientProtocolManagerFactory());
        ClientSessionFactory factory = createSessionFactory(locator);
        session = (ClientSessionInternal) factory.createSession();
        server.stop();
        Thread.sleep((pingPeriod * 2));
        List<String> incomings = server.getConfiguration().getIncomingInterceptorClassNames();
        incomings.add(UnsupportedPacketInterceptor.class.getName());
        server.start();
        // issue a query to make sure session is reconnected.
        ClientSession.QueueQuery query = session.queueQuery(new SimpleString("anyvalue"));
        assertFalse(query.isExists());
        locator.close();
        UnsupportedPacketInterceptor.checkReceivedTypes();
    } finally {
        try {
            session.close();
        } catch (Throwable e) {
        }
        server.stop();
    }
}
Also used : ClientSessionInternal(org.apache.activemq.artemis.core.client.impl.ClientSessionInternal) HornetQClientProtocolManagerFactory(org.apache.activemq.artemis.core.protocol.hornetq.client.HornetQClientProtocolManagerFactory) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Test(org.junit.Test)

Aggregations

SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)1 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)1 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)1 ClientSessionInternal (org.apache.activemq.artemis.core.client.impl.ClientSessionInternal)1 HornetQClientProtocolManagerFactory (org.apache.activemq.artemis.core.protocol.hornetq.client.HornetQClientProtocolManagerFactory)1 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)1 Test (org.junit.Test)1