From e99fc62e4a8fdb87b5e5446eef1d2abab24be4ea Mon Sep 17 00:00:00 2001 From: "Adrian T. Co" Date: Thu, 9 Feb 2006 06:43:10 +0000 Subject: [PATCH] - Added a message to the request map in failover before sending it to prevent race condition where the response tries (and fails) to remove the message before it is even added. This is to prevent double sending a message because it is still in the requestMap. (This is for the master-slave test cases) - Enabled a QueueBridgeTest, this test seems to pass already. - Some minor typo correction. git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@376206 13f79535-47bb-0310-9956-ffa450edef68 --- activemq-core/project.xml | 5 ++--- .../activemq/ConnectionFailedException.java | 2 +- .../transport/failover/FailoverTransport.java | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/activemq-core/project.xml b/activemq-core/project.xml index bda22ec76c..f5ad887af0 100755 --- a/activemq-core/project.xml +++ b/activemq-core/project.xml @@ -339,14 +339,13 @@ **/TcpTransportBrokerTest.* **/activeio/* - + **/perf/* **/ItStillMarshallsTheSameTest.* - **/QueueBridgeTest.* - + **/StompTest.* diff --git a/activemq-core/src/main/java/org/apache/activemq/ConnectionFailedException.java b/activemq-core/src/main/java/org/apache/activemq/ConnectionFailedException.java index caf5967ef3..e1345caac1 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ConnectionFailedException.java +++ b/activemq-core/src/main/java/org/apache/activemq/ConnectionFailedException.java @@ -37,7 +37,7 @@ public class ConnectionFailedException extends JMSException { } public ConnectionFailedException() { - super("The JMS connection has failed due ti a Transport problem"); + super("The JMS connection has failed due to a Transport problem"); } static private String extractMessage(IOException cause) { diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java b/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java index 3053030b87..b7a34024b2 100755 --- a/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java @@ -319,9 +319,6 @@ public class FailoverTransport implements CompositeTransport { } break; } - - // Send the message. - connectedTransport.oneway(command); // If it was a request and it was not being tracked by // the state tracker, @@ -330,6 +327,20 @@ public class FailoverTransport implements CompositeTransport { if (!stateTracker.track(command) && command.isResponseRequired()) { requestMap.put(new Short(command.getCommandId()), command); } + + // Send the message. + try { + connectedTransport.oneway(command); + } catch (IOException e) { + // If there is an IOException in the send, remove the command from the requestMap + if (!stateTracker.track(command) && command.isResponseRequired()) { + requestMap.remove(new Short(command.getCommandId()), command); + } + + // Rethrow the exception so it will handled by the outer catch + throw e; + } + return; }