From 50dadbb877a62b822057c8f44a8a865ceb3bd776 Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Mon, 1 Mar 2010 18:17:51 +0000 Subject: [PATCH] fix intermittent failure with test, was forwarding to same destination which made it timing dependent git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@917628 13f79535-47bb-0310-9956-ffa450edef68 --- .../failover/FailoverConsumerOutstandingCommitTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java b/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java index 79233fb6d4..3c0d70213b 100644 --- a/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java @@ -201,6 +201,8 @@ public class FailoverConsumerOutstandingCommitTest { @Override public void commitTransaction(ConnectionContext context, TransactionId xid, boolean onePhase) throws Exception { + // from the consumer perspective whether the commit completed on the broker or + // not is irrelevant, the transaction is still in doubt in the absence of a reply if (doActualBrokerCommit) { LOG.info("doing actual broker commit..."); super.commitTransaction(context, xid, onePhase); @@ -231,6 +233,10 @@ public class FailoverConsumerOutstandingCommitTest { final Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); final Queue destination = producerSession.createQueue(QUEUE_NAME + "?consumer.prefetchSize=" + prefetch); + + final Queue signalDestination = producerSession.createQueue(QUEUE_NAME + ".signal" + + "?consumer.prefetchSize=" + prefetch); + final Session consumerSession = connection.createSession(true, Session.SESSION_TRANSACTED); @@ -246,7 +252,7 @@ public class FailoverConsumerOutstandingCommitTest { assertNotNull("got message", message); receivedMessages.add((TextMessage) message); try { - produceMessage(consumerSession, destination, 1); + produceMessage(consumerSession, signalDestination, 1); consumerSession.commit(); } catch (JMSException e) { LOG.info("commit exception", e); @@ -286,6 +292,7 @@ public class FailoverConsumerOutstandingCommitTest { assertTrue("another message was received", messagesReceived.await(20, TimeUnit.SECONDS)); assertEquals("get message 1 eventually", MESSAGE_TEXT + "1", receivedMessages.get(2).getText()); + connection.close(); }