Author: gtully
Date: Fri Nov  7 04:51:54 2008
New Revision: 712117

URL: http://svn.apache.org/viewvc?rev=712117&view=rev
Log:
a test variant to validate AMQ-1957

Modified:
    
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java

Modified: 
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java?rev=712117&r1=712116&r2=712117&view=diff
==============================================================================
--- 
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java
 (original)
+++ 
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java
 Fri Nov  7 04:51:54 2008
@@ -623,4 +623,30 @@
         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();
+    }
+    
 }


Reply via email to