Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C59B0109B2 for ; Fri, 11 Oct 2013 19:14:18 +0000 (UTC) Received: (qmail 62747 invoked by uid 500); 11 Oct 2013 19:14:13 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 62435 invoked by uid 500); 11 Oct 2013 19:14:08 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 62196 invoked by uid 99); 11 Oct 2013 19:14:05 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Oct 2013 19:14:05 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id AF449915A88; Fri, 11 Oct 2013 19:14:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: chirino@apache.org To: commits@activemq.apache.org Date: Fri, 11 Oct 2013 19:14:07 -0000 Message-Id: In-Reply-To: <0fe45adc075c4b44ac352ea6ff5f36d4@git.apache.org> References: <0fe45adc075c4b44ac352ea6ff5f36d4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [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 Authored: Wed Jul 31 15:07:20 2013 +0000 Committer: Christian Posta 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 @@ localhost + 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