Author: cmoulliard Date: Tue Aug 24 12:17:33 2010 New Revision: 988501 URL: http://svn.apache.org/viewvc?rev=988501&view=rev Log: Add a new project to simulate high-volume (production & consumption) using camel routes + activemq.
Added: camel/trunk/tests/camel-itest-activemq-highvolume/ camel/trunk/tests/camel-itest-activemq-highvolume/pom.xml camel/trunk/tests/camel-itest-activemq-highvolume/src/ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/java/ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/java/org/ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/java/org/apache/ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/java/org/apache/camel/ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/java/org/apache/camel/itest/ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/java/org/apache/camel/itest/highvolume/ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/java/org/apache/camel/itest/highvolume/Messages.java camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/META-INF/ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/META-INF/activemq.xml camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/META-INF/spring/ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/META-INF/spring/camel-context.xml camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/log4j.properties camel/trunk/tests/camel-itest-activemq-highvolume/src/test/ Added: camel/trunk/tests/camel-itest-activemq-highvolume/pom.xml URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-activemq-highvolume/pom.xml?rev=988501&view=auto ============================================================================== --- camel/trunk/tests/camel-itest-activemq-highvolume/pom.xml (added) +++ camel/trunk/tests/camel-itest-activemq-highvolume/pom.xml Tue Aug 24 12:17:33 2010 @@ -0,0 +1,133 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + 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. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.camel</groupId> + <artifactId>camel-parent</artifactId> + <version>2.5-SNAPSHOT</version> + <!-- <version>2.4.0</version> --> + </parent> + + <artifactId>camel-itest-activemq-highvolume</artifactId> + <packaging>bundle</packaging> + <name>Camel :: ITest :: ActiveMq :: High Volume</name> + <description>Integration Test using ActiveMq with Camel to generate high volume messages</description> + + <properties> + <camel.osgi.import.pkg> + org.apache.activemq.broker, + org.apache.activemq.broker.region.policy, + org.apache.activemq.broker.region.virtual, + org.apache.activemq.usage, + org.apache.activemq.util, + org.apache.activemq.xbean, + org.springframework.jms.connection;version="3.0.3.RELEASE", + * + </camel.osgi.import.pkg> + <camel.osgi.private.pkg> + org.apache.camel.itest.highvolume + </camel.osgi.private.pkg> + <camel.osgi.dynamic> + * + </camel.osgi.dynamic> + </properties> + + <dependencies> + <!-- Camel --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core-xml</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jms</artifactId> + </dependency> + + <!-- Spring --> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + </dependency> + + <!-- ActiveMq & activemq - camel --> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-pool</artifactId> + <version>5.3.2</version> + </dependency> + <dependency> + <groupId>org.apache.xbean</groupId> + <artifactId>xbean-spring</artifactId> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-camel</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + + <!-- Allows the example to be run via 'mvn compile exec:java' --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <configuration> + <includePluginDependencies>false</includePluginDependencies> + </configuration> + </plugin> + + <!-- Allows the routes to be run via 'mvn camel:run' --> + <plugin> + <groupId>org.apache.camel</groupId> + <artifactId>camel-maven-plugin</artifactId> + </plugin> + </plugins> + </build> + +</project> Added: camel/trunk/tests/camel-itest-activemq-highvolume/src/main/java/org/apache/camel/itest/highvolume/Messages.java URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-activemq-highvolume/src/main/java/org/apache/camel/itest/highvolume/Messages.java?rev=988501&view=auto ============================================================================== --- camel/trunk/tests/camel-itest-activemq-highvolume/src/main/java/org/apache/camel/itest/highvolume/Messages.java (added) +++ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/java/org/apache/camel/itest/highvolume/Messages.java Tue Aug 24 12:17:33 2010 @@ -0,0 +1,34 @@ +package org.apache.camel.itest.highvolume; + +import org.apache.camel.EndpointInject; +import org.apache.camel.Exchange; +import org.apache.camel.Handler; +import org.apache.camel.ProducerTemplate; +import org.springframework.beans.factory.annotation.Autowired; + +public class Messages { + + @EndpointInject(ref="Direct") + ProducerTemplate template; + + @EndpointInject(ref="JmsQueueProducer") + ProducerTemplate templateActiveMq; + + public void split(Exchange exchange) { + String messages = (String) exchange.getIn().getBody(); + + String[] result = messages.split(","); + for (int x=0; x<result.length; x++) { + templateActiveMq.sendBody(result[x]); + } + } + + public void generate(Exchange exchange) { + StringBuilder messages = new StringBuilder(); + for (int i = 1; i < 1000; i++) { + messages.append("Test Message: " + i + ","); + } + template.sendBody(messages.toString()); + } + +} Added: camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/META-INF/activemq.xml URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/META-INF/activemq.xml?rev=988501&view=auto ============================================================================== --- camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/META-INF/activemq.xml (added) +++ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/META-INF/activemq.xml Tue Aug 24 12:17:33 2010 @@ -0,0 +1,115 @@ +<!-- + 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. +--> +<!-- +<beans + xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://activemq.apache.org/schema/core + http://activemq.apache.org/schema/core/activemq-core-5.3.0.xsd"> +--> +<beans + xmlns="http://www.springframework.org/schema/beans" + xmlns:amq="http://activemq.apache.org/schema/core" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:osgi="http://www.springframework.org/schema/osgi" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd + http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd + http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd + http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd"> + + <!-- + The <broker> element is used to configure the ActiveMQ broker. + --> + <broker xmlns="http://activemq.apache.org/schema/core" + brokerName="brokerHighVolume" + persistent="false" + useJmx="true" + enableStatistics="true" + advisorySupport="false"> + + <destinationInterceptors> + <virtualDestinationInterceptor> + <virtualDestinations> + <virtualTopic name=">" prefix="VirtualQueueConsumer." /> + </virtualDestinations> + </virtualDestinationInterceptor> + </destinationInterceptors> + + <destinationPolicy> + <policyMap> + <policyEntries> + <policyEntry topic=">" producerFlowControl="true" memoryLimit="1mb"> + <pendingSubscriberPolicy> + <vmCursor /> + </pendingSubscriberPolicy> + </policyEntry> + + <policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb"> + <pendingQueuePolicy> + <vmQueueCursor/> + </pendingQueuePolicy> + </policyEntry> + </policyEntries> + </policyMap> + </destinationPolicy> + + <!-- The store and forward broker networks ActiveMQ will listen to --> + <networkConnectors/> + + <!-- + <persistenceAdapter> + <kahaDB directory="data/kahadb"/> + </persistenceAdapter> + --> + + + <!-- + The systemUsage controls the maximum amount of space the broker will + use before slowing down producers. For more information, see: + + http://activemq.apache.org/producer-flow-control.html + --> + <systemUsage> + <systemUsage sendFailIfNoSpace="true"> + <memoryUsage> + <memoryUsage limit="256 mb"/> + </memoryUsage> + <storeUsage> + <storeUsage limit="1 gb" name="foo"/> + </storeUsage> + <tempUsage> + <tempUsage limit="100 mb"/> + </tempUsage> + </systemUsage> + </systemUsage> + + + <!-- + The transport connectors expose ActiveMQ over a given protocol to + clients and other brokers. For more information, see: + + http://activemq.apache.org/configuring-transports.html + --> + <transportConnectors> + <transportConnector name="tcp" uri="tcp://0.0.0.0:61616" /> + </transportConnectors> + + </broker> + +</beans> Added: camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/META-INF/spring/camel-context.xml URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/META-INF/spring/camel-context.xml?rev=988501&view=auto ============================================================================== --- camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/META-INF/spring/camel-context.xml (added) +++ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/META-INF/spring/camel-context.xml Tue Aug 24 12:17:33 2010 @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://camel.apache.org/schema/spring + http://camel.apache.org/schema/spring/camel-spring.xsd"> + + <camelContext xmlns="http://camel.apache.org/schema/spring"> + + <endpoint id="Timer" uri="timer:messages?period=1s"/> + <endpoint id="Direct" uri="direct:messages"/> + <endpoint id="Split" uri="bean:messages?method=split"/> + <endpoint id="GenerateMessages" uri="bean:messages?method=generate"/> + <endpoint id="JmsQueueProducer" uri="jmsProducer:topic:highVolume"/> + <endpoint id="JmsQueueConsumer" uri="jmsConsumer:queue:VirtualQueueConsumer.highVolume?concurrentConsumers=1"/> + <endpoint id="Log" uri="log:org.apache.camel.example?level=WARN"/> + + <route id="ProduceMessages" trace="false"> + <from ref="Timer"/> + <to ref="GenerateMessages"/> + </route> + + <route id="SplitandProduceMessagesOnActiveMq" trace="false"> + <from ref="Direct"/> + <doTry> + <to ref="Split"/> + <to uri="JmsQueueProducer"/> + <doCatch> + <exception>javax.jms.ResourceAllocationException</exception> + <log message=">>>>>> PRODUCER SHOULD BE STOPPED"/> + </doCatch> + </doTry> + </route> + + <route id="ConsumeMessages" trace="false"> + <from ref="JmsQueueConsumer"/> + <delay> + <constant>100</constant> + </delay> + <to ref="Log"/> + </route> + + </camelContext> + + <!-- ******************************************************************************************* --> + + <!-- Create an embedded broker --> + <bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean"> + <property name="config" value="classpath:META-INF/activemq.xml" /> + <property name="start" value="true" /> + </bean> + + + <!-- ******************************************************************************************* --> + + <!-- Config used when we produce the messages + protocol vm:// is used + and connection pool + --> + + <!-- Connection for the client producing --> + <bean id="jmsConnectionFactoryProducer" class="org.apache.activemq.ActiveMQConnectionFactory"> + <property name="brokerURL" value="vm://localhost:61616" /> + </bean> + + <bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"> + <property name="maxConnections" value="10" /> + <property name="maximumActive" value="500" /> + <property name="connectionFactory" ref="jmsConnectionFactoryProducer" /> + </bean> + + <!-- Use pooled connection factory to produce messages --> + <bean id="jmsConfigProducer" class="org.apache.camel.component.jms.JmsConfiguration"> + <property name="connectionFactory" ref="pooledConnectionFactory"/> + <property name="transacted" value="false"/> + </bean> + + <bean id="jmsProducer" class="org.apache.activemq.camel.component.ActiveMQComponent"> + <property name="configuration" ref="jmsConfigProducer"/> + </bean> + + <!-- ******************************************************************************************* --> + <!-- Config used to consume the messages + Transport layer is different tcp:// instead of vm:// + and not connection pool is used --> + + <!-- Connection for the client consuming --> + <bean id="jmsConnectionFactoryConsumer" class="org.apache.activemq.ActiveMQConnectionFactory"> + <property name="brokerURL" value="tcp://localhost:61616" /> + </bean> + + <!-- Use simple connection factory to consume messages --> + <bean id="jmsConfigConsumer" class="org.apache.camel.component.jms.JmsConfiguration"> + <property name="connectionFactory" ref="jmsConnectionFactoryConsumer"/> + <property name="transacted" value="false"/> + </bean> + + <bean id="jmsConsumer" class="org.apache.activemq.camel.component.ActiveMQComponent"> + <property name="configuration" ref="jmsConfigConsumer"/> + + </bean> + + <!-- ******************************************************************************************* --> + + <bean name="messages" class="org.apache.camel.itest.highvolume.Messages" /> + +</beans> \ No newline at end of file Added: camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/log4j.properties URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/log4j.properties?rev=988501&view=auto ============================================================================== --- camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/log4j.properties (added) +++ camel/trunk/tests/camel-itest-activemq-highvolume/src/main/resources/log4j.properties Tue Aug 24 12:17:33 2010 @@ -0,0 +1,38 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests.. +# +log4j.rootLogger=WARN, out + +# Use the following line to turn on debug output for camel +#log4j.logger.org.apache.camel=DEBUG + +log4j.logger.org.apache.activemq.spring=WARN + +# CONSOLE appender not used by default +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n + +# File appender +log4j.appender.out=org.apache.log4j.FileAppender +log4j.appender.out.layout=org.apache.log4j.PatternLayout +log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +log4j.appender.out.file=target/camel-itest-activemq-highvolume-test.log +log4j.appender.out.append=true