Search in sources :

Example 1 with CreateSessionMessage

use of org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionMessage in project activemq-artemis by apache.

the class IncompatibleVersionTest method doTestClientVersionCompatibility.

private void doTestClientVersionCompatibility(boolean compatible) throws Exception {
    Channel channel1 = connection.getChannel(1, -1);
    long sessionChannelID = connection.generateChannelID();
    int version = VersionLoader.getVersion().getIncrementingVersion();
    if (!compatible) {
        version = -1;
    }
    Packet request = new CreateSessionMessage(randomString(), sessionChannelID, version, null, null, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, false, true, true, false, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, null);
    if (compatible) {
        CreateSessionResponseMessage packet = (CreateSessionResponseMessage) channel1.sendBlocking(request, PacketImpl.CREATESESSION_RESP);
        assertNotNull(packet);
        // 1 connection on the server
        assertEquals(1, server.getConnectionCount());
    } else {
        try {
            channel1.sendBlocking(request, PacketImpl.CREATESESSION_RESP);
            fail();
        } catch (ActiveMQIncompatibleClientServerException icsv) {
        // ok
        } catch (ActiveMQException e) {
            fail("Invalid Exception type:" + e.getType());
        }
        long start = System.currentTimeMillis();
        while (System.currentTimeMillis() < start + 3 * server.getConfiguration().getConnectionTtlCheckInterval()) {
            if (server.getConnectionCount() == 0) {
                break;
            }
        }
        // no connection on the server
        assertEquals(0, server.getConnectionCount());
    }
}
Also used : Packet(org.apache.activemq.artemis.core.protocol.core.Packet) CreateSessionResponseMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionResponseMessage) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) Channel(org.apache.activemq.artemis.core.protocol.core.Channel) ActiveMQIncompatibleClientServerException(org.apache.activemq.artemis.api.core.ActiveMQIncompatibleClientServerException) CreateSessionMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionMessage)

Aggregations

ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 ActiveMQIncompatibleClientServerException (org.apache.activemq.artemis.api.core.ActiveMQIncompatibleClientServerException)1 Channel (org.apache.activemq.artemis.core.protocol.core.Channel)1 Packet (org.apache.activemq.artemis.core.protocol.core.Packet)1 CreateSessionMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionMessage)1 CreateSessionResponseMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionResponseMessage)1