Don't send the ShutdownInfo when stopping the transport. This should make it faster to shutdown a failed connection.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@638358 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2008-03-18 13:18:22 +00:00
parent e58dfee8cc
commit eccb337303
2 changed files with 9 additions and 17 deletions

View File

@ -925,11 +925,6 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
if (duplexBridge != null) {
duplexBridge.stop();
}
// If the transport has not failed yet,
// notify the peer that we are doing a normal shutdown.
if (transportException == null) {
transport.oneway(new ShutdownInfo());
}
}
} catch (Exception ignore) {
@ -943,12 +938,6 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
cs.getContext().getStopping().set(true);
}
if (taskRunner != null) {
taskRunner.wakeup();
// Give it a change to stop gracefully.
dispatchStoppedLatch.await(5, TimeUnit.SECONDS);
}
try {
transport.stop();
LOG.debug("Stopped connection: " + transport.getRemoteAddress());
@ -957,6 +946,9 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
}
if (taskRunner != null) {
taskRunner.wakeup();
// Give it a change to stop gracefully.
dispatchStoppedLatch.await(5, TimeUnit.SECONDS);
taskRunner.shutdown();
}

View File

@ -19,6 +19,7 @@ package org.apache.activemq.broker;
import java.io.IOException;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.activemq.Service;
import org.apache.activemq.command.Command;
@ -40,6 +41,7 @@ public class StubConnection implements Service {
private Transport transport;
private boolean shuttingDown;
private TransportListener listener;
public AtomicReference<Throwable> error = new AtomicReference<Throwable>();
public StubConnection(BrokerService broker) throws Exception {
this(TransportFactory.connect(broker.getVmConnectorURI()));
@ -63,13 +65,11 @@ public class StubConnection implements Service {
}
}
public void onException(IOException error) {
public void onException(IOException e) {
if (listener != null) {
listener.onException(error);
}
if (!shuttingDown) {
error.printStackTrace();
listener.onException(e);
}
error.set(e);
}
});
transport.start();