From a15e6efabd94fd74fcdd28c3326f3096b9b7bbec Mon Sep 17 00:00:00 2001 From: Bosanac Dejan Date: Fri, 14 Aug 2009 12:29:58 +0000 Subject: [PATCH] https://issues.apache.org/activemq/browse/AMQ-1807 - aborting transaction test revisited + solution git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@804192 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/activemq/transport/stomp/StompConnection.java | 9 +++++++++ .../org/apache/activemq/transport/stomp/StompTest.java | 1 + 2 files changed, 10 insertions(+) diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompConnection.java b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompConnection.java index db68061eaa..cddd51a19f 100644 --- a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompConnection.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompConnection.java @@ -188,6 +188,15 @@ public class StompConnection { } public void abort(String transaction) throws Exception { + // discard all content on the wire before + // aborting the transaction + try { + StompFrame discarded = this.receive(100); + while (discarded != null) { + discarded = this.receive(100); + } + } catch (Exception e) { + } HashMap headers = new HashMap(); headers.put("transaction", transaction); StompFrame frame = new StompFrame("ABORT", headers); diff --git a/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java b/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java index 48c766603a..17bdade714 100644 --- a/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java @@ -972,6 +972,7 @@ public class StompTest extends CombinationTestSupport { } catch (SocketTimeoutException soe) {} stompConnection.ack(frame1, "tx1"); + Thread.sleep(1000); stompConnection.abort("tx1"); stompConnection.begin("tx2");