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");