From 92e143155b636dd2a6f6730fb5c65dbb8d1ec970 Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Fri, 7 Nov 2008 12:51:54 +0000 Subject: [PATCH] a test variant to validate AMQ-1957 git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@712117 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/activemq/JMSConsumerTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java b/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java index 0c903db28d..2c781011c8 100755 --- a/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java @@ -623,4 +623,30 @@ public class JMSConsumerTest extends JmsTestSupport { consumer = session.createConsumer(destination); assertNull(consumer.receive(1000)); } + + public void testRedispatchOfUncommittedTx() throws Exception { + + connection.start(); + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE); + + sendMessages(connection, destination, 1); + + MessageConsumer consumer = session.createConsumer(destination); + assertNotNull(consumer.receive(1000)); + + // install another consumer while message dispatch is unacked/uncommitted + Session redispatchSession = connection.createSession(true, Session.SESSION_TRANSACTED); + MessageConsumer redispatchConsumer = redispatchSession.createConsumer(destination); + + // no commit so will auto rollback and get redispatched to redisptachConsumer + session.close(); + + assertNotNull(redispatchConsumer.receive(1000)); + redispatchSession.commit(); + + assertNull(redispatchConsumer.receive(500)); + redispatchSession.close(); + } + }