a test variant to validate AMQ-1957

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@712117 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2008-11-07 12:51:54 +00:00
parent c57afb6289
commit 92e143155b
1 changed files with 26 additions and 0 deletions

View File

@ -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();
}
}