You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2013/10/11 21:14:07 UTC
[03/14] git commit: Added test for openwire DLQ handling w/
redelivery policy to answer question from mailing list
Added test for openwire DLQ handling w/ redelivery policy to answer question from mailing list
git-svn-id: https://svn.apache.org/repos/asf/activemq/activemq-apollo/trunk@1508902 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/activemq-apollo/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-apollo/commit/bfd24ee0
Tree: http://git-wip-us.apache.org/repos/asf/activemq-apollo/tree/bfd24ee0
Diff: http://git-wip-us.apache.org/repos/asf/activemq-apollo/diff/bfd24ee0
Branch: refs/heads/trunk
Commit: bfd24ee053591f7a265e6e18d77d8b893a63db5b
Parents: 9312e55
Author: Christian Posta <ce...@apache.org>
Authored: Wed Jul 31 15:07:20 2013 +0000
Committer: Christian Posta <ce...@apache.org>
Committed: Wed Jul 31 15:07:20 2013 +0000
----------------------------------------------------------------------
.../src/test/resources/apollo-openwire.xml | 1 +
.../openwire/test/OpenwireParallelTest.scala | 36 ++++++++++++++++++++
2 files changed, 37 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/bfd24ee0/apollo-openwire/src/test/resources/apollo-openwire.xml
----------------------------------------------------------------------
diff --git a/apollo-openwire/src/test/resources/apollo-openwire.xml b/apollo-openwire/src/test/resources/apollo-openwire.xml
index 3a7d7ba..6f7b3a5 100644
--- a/apollo-openwire/src/test/resources/apollo-openwire.xml
+++ b/apollo-openwire/src/test/resources/apollo-openwire.xml
@@ -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"/>-->
http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/bfd24ee0/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala
----------------------------------------------------------------------
diff --git a/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala b/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala
index 0248c04..c8be2f8 100644
--- a/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala
+++ b/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala
@@ -18,6 +18,7 @@ package org.apache.activemq.apollo.openwire.test
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 OpenwireTestSupport with BrokerParallelTestEx
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