activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cepo...@apache.org
Subject svn commit: r1508902 - in /activemq/activemq-apollo/trunk/apollo-openwire/src/test: resources/apollo-openwire.xml scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala
Date Wed, 31 Jul 2013 15:07:21 GMT
Author: ceposta
Date: Wed Jul 31 15:07:20 2013
New Revision: 1508902

URL: http://svn.apache.org/r1508902
Log:
Added test for openwire DLQ handling w/ redelivery policy to answer question from mailing
list

Modified:
    activemq/activemq-apollo/trunk/apollo-openwire/src/test/resources/apollo-openwire.xml
    activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala

Modified: activemq/activemq-apollo/trunk/apollo-openwire/src/test/resources/apollo-openwire.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-openwire/src/test/resources/apollo-openwire.xml?rev=1508902&r1=1508901&r2=1508902&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-openwire/src/test/resources/apollo-openwire.xml
(original)
+++ activemq/activemq-apollo/trunk/apollo-openwire/src/test/resources/apollo-openwire.xml
Wed Jul 31 15:07:20 2013
@@ -21,6 +21,7 @@
 
   <virtual_host id="default">
       <host_name>localhost</host_name>
+      <queue id="nacker.**" dlq="dlq.*" dlq_expired="true" nak_limit="1"/>
   </virtual_host>
 
   <!--<web_admin bind="http://0.0.0.0:61680"/>-->

Modified: activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala?rev=1508902&r1=1508901&r2=1508902&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala
Wed Jul 31 15:07:20 2013
@@ -18,6 +18,7 @@ package org.apache.activemq.apollo.openw
 
 import javax.jms._
 import org.apache.activemq.apollo.broker.BrokerParallelTestExecution
+import org.apache.activemq.{ActiveMQConnection, RedeliveryPolicy}
 
 class OpenwireParallelTest extends OpenwireTestSupport with BrokerParallelTestExecution {
 
@@ -747,4 +748,39 @@ class OpenwireParallelTest extends Openw
     receive_text(localConsumer) should equal("1")
     receive_text(localConsumer) should equal("3")
  }
+
+  test("Rollback moves messages to DLQ"){
+    connect()
+    val redelivery_policy = new RedeliveryPolicy
+    redelivery_policy.setMaximumRedeliveries(1)
+    default_connection.asInstanceOf[ActiveMQConnection].setRedeliveryPolicy(redelivery_policy)
+
+    // send our message
+    val producerSession = default_connection.createSession(false, Session.AUTO_ACKNOWLEDGE)
+    val destination = producerSession.createQueue("nacker.test")
+    val producer = producerSession.createProducer(destination)
+    producer.send(producerSession.createTextMessage("yo"))
+    producerSession.close()
+
+    // consume and rollback
+    val consumerSession = default_connection.createSession(true, Session.SESSION_TRANSACTED)
+    val destination2 = consumerSession.createQueue("nacker.test")
+    val consumer = consumerSession.createConsumer(destination2)
+
+    var msg = consumer.receive(1000)
+    msg should not be null
+    consumerSession.rollback()
+
+    msg = consumer.receive(1500)
+    msg should not be null
+    consumerSession.rollback()
+
+    consumerSession.close()
+
+    val dlqSession = default_connection.createSession(false, Session.AUTO_ACKNOWLEDGE)
+    val dlq = dlqSession.createQueue("dlq.nacker.test")
+    val dlqConsumer = dlqSession.createConsumer(dlq)
+    val dlqMsg = dlqConsumer.receive(1000)
+    dlqMsg should not be null
+  }
 }
\ No newline at end of file



Mime
View raw message