Await TcpClient shutdown in STOMP broker relay

This commit is contained in:
Rossen Stoyanchev
2014-05-15 22:00:17 -04:00
parent 8ee4651038
commit 673a497923
2 changed files with 10 additions and 3 deletions

View File

@@ -128,10 +128,13 @@ public abstract class AbstractBrokerMessageHandler
public final void start() {
synchronized (this.lifecycleMonitor) {
if (logger.isDebugEnabled()) {
logger.debug("Starting " + getClass().getSimpleName());
logger.debug("Starting");
}
startInternal();
this.running = true;
if (logger.isDebugEnabled()) {
logger.debug("Started");
}
}
}
@@ -142,10 +145,13 @@ public abstract class AbstractBrokerMessageHandler
public final void stop() {
synchronized (this.lifecycleMonitor) {
if (logger.isDebugEnabled()) {
logger.debug("Stopping " + getClass().getSimpleName());
logger.debug("Stopping");
}
stopInternal();
this.running = false;
if (logger.isDebugEnabled()) {
logger.debug("Stopped");
}
}
}

View File

@@ -20,6 +20,7 @@ import java.util.Collection;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
@@ -384,7 +385,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
this.brokerChannel.unsubscribe(this);
try {
this.tcpClient.shutdown();
this.tcpClient.shutdown().get(5000, TimeUnit.MILLISECONDS);
}
catch (Throwable t) {
logger.error("Error while shutting down TCP client", t);