Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -802,13 +802,20 @@ private boolean reconnectSessions(final RemotingConnection oldConnection,
// it needs to be done on the protocol
((CoreRemotingConnection) connection).syncIDGeneratorSequence(((CoreRemotingConnection) oldConnection).getIDGeneratorSequence());

boolean sessionFailoverError = false;
for (ClientSessionInternal session : sessionsToFailover) {
if (!session.handleFailover(connection, cause)) {
return false;
if (sessionFailoverError) {
// If 1 session had a failover error, just detach the remaining sessions from the old connection so that
// they are not closed when the old connection is destroyed
session.getSessionContext().transferConnection(connection);
} else {
if (!session.handleFailover(connection, cause)) {
sessionFailoverError = true;
}
}
}

return true;
return !sessionFailoverError;
}

private void getConnectionWithRetry(final int reconnectAttempts, RemotingConnection oldConnection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -823,11 +823,15 @@ public void createQueue(QueueConfiguration queueConfiguration) throws ActiveMQEx
}

@Override
public boolean reattachOnNewConnection(RemotingConnection newConnection) throws ActiveMQException {

public void transferConnection(RemotingConnection newConnection) {
this.remotingConnection = newConnection;

sessionChannel.transferConnection((CoreRemotingConnection) newConnection);
}

@Override
public boolean reattachOnNewConnection(RemotingConnection newConnection) throws ActiveMQException {

transferConnection(newConnection);

Packet request = new ReattachSessionMessage(name, sessionChannel.getLastConfirmedCommandID());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ public void setSession(ClientSessionInternal session) {

public abstract int getReconnectID();

/**
* Transfers the session context to the given newConnection on the client-side
*/
public abstract void transferConnection(RemotingConnection newConnection);

/**
* it will either reattach or reconnect, preferably reattaching it.
*
Expand Down