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;
}
}
Aggregations