From 86dc4d5c345423d55569c5da45177d41322ac1e0 Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Fri, 26 Aug 2011 11:04:14 +0000 Subject: [PATCH] test to explore concurrent transacted consumption with camel and prefetch implications of pooling git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1162061 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/camel/TransactedConsumeTest.java | 123 ++++++++++++++++++ .../activemq/camel/transactedconsume.xml | 78 +++++++++++ 2 files changed, 201 insertions(+) create mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/TransactedConsumeTest.java create mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/transactedconsume.xml diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/TransactedConsumeTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/TransactedConsumeTest.java new file mode 100644 index 0000000000..a325248807 --- /dev/null +++ b/activemq-camel/src/test/java/org/apache/activemq/camel/TransactedConsumeTest.java @@ -0,0 +1,123 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.camel; + +import javax.jms.Connection; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.region.policy.PolicyEntry; +import org.apache.activemq.broker.region.policy.PolicyMap; +import org.apache.activemq.command.ActiveMQQueue; +import org.apache.activemq.command.ActiveMQTextMessage; +import org.apache.activemq.util.Wait; +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.component.jms.JmsMessage; +import org.apache.camel.test.junit4.CamelSpringTestSupport; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class TransactedConsumeTest extends CamelSpringTestSupport { + private static final Logger LOG = LoggerFactory.getLogger(TransactedConsumeTest.class); + BrokerService broker = null; + int messageCount = 1000; + + @Test + public void testConsume() throws Exception { + + LOG.info("Wait for dequeue message..."); + + assertTrue(Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + return broker.getAdminView().getTotalDequeueCount() >= messageCount; + } + }, 20 * 60 * 1000)); + } + + private void sendJMSMessageToKickOffRoute() throws Exception { + ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://test"); + factory.setWatchTopicAdvisories(false); + Connection connection = factory.createConnection(); + connection.start(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer producer = session.createProducer(new ActiveMQQueue("scp_transacted")); + for (int i=0; i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +