ARTEMIS-1927 treat exceptions and disconnect properly

I couldn't do this with a test as this is dependent on windows. Regular testsuite should be sufficient as long as you run in Windows.
This commit is contained in:
Clebert Suconic 2018-06-12 16:29:13 -04:00
parent 1d5128839f
commit 88833c790a
2 changed files with 7 additions and 11 deletions

View File

@ -26,7 +26,6 @@ import io.netty.channel.group.ChannelGroup;
import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper; import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; import org.apache.activemq.artemis.core.client.ActiveMQClientLogger;
import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle;
import org.apache.activemq.artemis.spi.core.remoting.BaseConnectionLifeCycleListener; import org.apache.activemq.artemis.spi.core.remoting.BaseConnectionLifeCycleListener;
import org.apache.activemq.artemis.spi.core.remoting.BufferHandler; import org.apache.activemq.artemis.spi.core.remoting.BufferHandler;
@ -99,7 +98,7 @@ public class ActiveMQChannelHandler extends ChannelDuplexHandler {
// and we don't want to spew out stack traces in that event // and we don't want to spew out stack traces in that event
// The user has access to this exeception anyway via the ActiveMQException initial cause // The user has access to this exeception anyway via the ActiveMQException initial cause
ActiveMQException me = ActiveMQClientMessageBundle.BUNDLE.nettyError(); ActiveMQException me = new ActiveMQException(cause.getMessage());
me.initCause(cause); me.initCause(cause);
synchronized (listener) { synchronized (listener) {

View File

@ -539,6 +539,10 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
logger.trace("Connection removed " + connectionID + " from server " + this.server, new Exception("trace")); logger.trace("Connection removed " + connectionID + " from server " + this.server, new Exception("trace"));
} }
issueFailure(connectionID, new ActiveMQRemoteDisconnectException());
}
private void issueFailure(Object connectionID, ActiveMQException e) {
ConnectionEntry conn = connections.get(connectionID); ConnectionEntry conn = connections.get(connectionID);
if (conn != null && !conn.connection.isSupportReconnect()) { if (conn != null && !conn.connection.isSupportReconnect()) {
@ -554,20 +558,13 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
return; return;
} }
} }
conn.connection.fail(new ActiveMQRemoteDisconnectException()); conn.connection.fail(e);
} }
} }
@Override @Override
public void connectionException(final Object connectionID, final ActiveMQException me) { public void connectionException(final Object connectionID, final ActiveMQException me) {
// We DO NOT call fail on connection exception, otherwise in event of real connection failure, the issueFailure(connectionID, me);
// connection will be failed, the session will be closed and won't be able to reconnect
// E.g. if live server fails, then this handler wil be called on backup server for the server
// side replicating connection.
// If the connection fail() is called then the sessions on the backup will get closed.
// Connections should only fail when TTL is exceeded
} }
@Override @Override