Search in sources :

Example 1 with ReattachSessionMessage

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

the class ActiveMQSessionContext method reattachOnNewConnection.

@Override
public boolean reattachOnNewConnection(RemotingConnection newConnection) throws ActiveMQException {
    this.remotingConnection = newConnection;
    sessionChannel.transferConnection((CoreRemotingConnection) newConnection);
    Packet request = new ReattachSessionMessage(name, sessionChannel.getLastConfirmedCommandID());
    Channel channel1 = getCoreConnection().getChannel(1, -1);
    ReattachSessionResponseMessage response = (ReattachSessionResponseMessage) channel1.sendBlocking(request, PacketImpl.REATTACH_SESSION_RESP);
    if (response.isReattached()) {
        ActiveMQClientLogger.LOGGER.replayingCommands(sessionChannel.getID(), response.getLastConfirmedCommandID());
        // The session was found on the server - we reattached transparently ok
        sessionChannel.replayCommands(response.getLastConfirmedCommandID());
        return true;
    } else {
        ActiveMQClientLogger.LOGGER.reconnectCreatingNewSession(sessionChannel.getID());
        sessionChannel.clearCommands();
        return false;
    }
}
Also used : Packet(org.apache.activemq.artemis.core.protocol.core.Packet) ReattachSessionMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReattachSessionMessage) Channel(org.apache.activemq.artemis.core.protocol.core.Channel) ReattachSessionResponseMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReattachSessionResponseMessage)

Aggregations

Channel (org.apache.activemq.artemis.core.protocol.core.Channel)1 Packet (org.apache.activemq.artemis.core.protocol.core.Packet)1 ReattachSessionMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReattachSessionMessage)1 ReattachSessionResponseMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReattachSessionResponseMessage)1