From 4240bf2abbcd48127b889a5197d05d193ab0b2c8 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Mon, 24 Nov 2008 12:47:04 +0000 Subject: QPID-1480 : Updated Simple Request Response code to loop on the shutdownHook to ensure that it is zero before exit. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@720183 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/example/simple/reqresp/Server.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'java/client/example/src') diff --git a/java/client/example/src/main/java/org/apache/qpid/example/simple/reqresp/Server.java b/java/client/example/src/main/java/org/apache/qpid/example/simple/reqresp/Server.java index 63c7e95705..9c284eee97 100644 --- a/java/client/example/src/main/java/org/apache/qpid/example/simple/reqresp/Server.java +++ b/java/client/example/src/main/java/org/apache/qpid/example/simple/reqresp/Server.java @@ -65,7 +65,7 @@ public class Server implements MessageListener { setupJNDI(); - Connection connection = null; + Connection connection; try { connection = ((ConnectionFactory) lookupJNDI(CONNECTION_JNDI_NAME)).createConnection(); @@ -97,13 +97,16 @@ public class Server implements MessageListener System.out.println("Server process started and waiting for messages."); //Wait to process an single message then quit. - try - { - _shutdownHook.await(); - } - catch (InterruptedException e) + while (_shutdownHook.getCount() != 0) { - // Ignore this as we are quitting anyway. + try + { + _shutdownHook.await(); + } + catch (InterruptedException e) + { + // Ignore this as we are quitting anyway. + } } //Close the connection -- cgit v1.2.1