added a local broker load test

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@687033 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2008-08-19 12:05:45 +00:00
parent 1d9a6c1cc8
commit 0a997b7eae
4 changed files with 161 additions and 2 deletions

View File

@ -0,0 +1,63 @@
/**
*
* 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.soaktest.localBroker;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
/**
* @version $Revision: 1.1 $
*/
public class CounterBean implements InitializingBean, Processor {
private static final transient Log LOG = LogFactory.getLog(CounterBean.class);
protected static final long SAMPLES = Integer.parseInt(System.getProperty("SAMPLES", "" + 10000));
protected static final long SAMPLE_DURATION = Integer.parseInt(System.getProperty("SAMPLES_DURATION", "" + 1000 * 5));
final AtomicLong counter = new AtomicLong();
public void process(Exchange exchange) throws Exception {
counter.incrementAndGet();
}
public void afterPropertiesSet() throws Exception {
Thread thread = new Thread() {
@Override
public void run() {
LOG.info("Starting to monitor consumption");
for (int i = 0; i < SAMPLES; i++) {
try {
Thread.sleep(SAMPLE_DURATION);
}
catch (InterruptedException e) {
LOG.warn("Caught: " + e, e);
}
long count = counter.getAndSet(0);
LOG.info(" Total: " + (1000.0 * count / SAMPLE_DURATION) + " messages per second.");
}
}
};
thread.setDaemon(false);
thread.start();
}
}

View File

@ -0,0 +1,40 @@
/**
*
* 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.soaktest.localBroker;
import org.apache.camel.CamelContext;
import org.apache.camel.component.mock.MockEndpoint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
/**
* Runs a load test on a separate broker on localhost
*
* @version $Revision: 1.1 $
*/
@ContextConfiguration
public class LocalBrokerConsumeTest extends AbstractJUnit38SpringContextTests {
@Autowired
protected CamelContext camelContext;
public void testRun() throws Exception {
Thread.sleep(100000);
//MockEndpoint.assertIsSatisfied(camelContext);
}
}

View File

@ -0,0 +1,47 @@
<?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.
-->
<!-- START SNIPPET: example -->
<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-2.0.xsd
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
http://activemq.org/config/1.0 http://activemq.apache.org/schema/core/activemq-core-5.0.0.xsd
">
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="activemq:TEST?concurrentConsumers=1"/>
<process ref="counter"/>
<!--<to uri="mock:results?expectedMessageCount=100000&amp;reportGroup=5000&amp;resultWaitTime=400000"/>-->
</route>
</camelContext>
<bean id="counter" class="org.apache.activemq.soaktest.localBroker.CounterBean"/>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://localhost:61616"/>
<property name="usePooledConnection" value="false"/>
<property name="useSingleConnection" value="false"/>
<property name="acknowledgementModeName" value="AUTO_ACKNOWLEDGE"/>
<property name="transacted" value="false"/>
</bean>
</beans>
<!-- END SNIPPET: example -->

View File

@ -30,16 +30,17 @@
<from uri="dataset:myDataSet?preloadSize=50000"/>
<to uri="activemq:foo.example.A"/>
<!-- lets use concurrency -->
<!--
<to uri="activemq:foo.example.A"/>
<thread coreSize="10" maxSize="20">
</thread>
-->
</route>
<route>
<from uri="activemq:foo.example.A?concurrentConsumers=5"/>
<from uri="activemq:foo.example.A?concurrentConsumers=20"/>
<to uri="mock:results?expectedMessageCount=100000&amp;reportGroup=5000&amp;resultWaitTime=400000"/>
</route>
@ -51,6 +52,14 @@
</bean>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<!--<property name="brokerURL" value="tcp://localhost:61616?wireFormat.tightEncodingEnabled=false"/>-->
<property name="brokerURL" value="tcp://localhost:61616?wireFormat.tightEncodingEnabled=false&amp;jms.dispatchAsync=true"/>
<property name="deliveryPersistent" value="false"/>
<property name="acknowledgementModeName" value="DUPS_OK_ACKNOWLEDGE"/>
<!--<property name="transacted" value="true"/>-->
<property name="transacted" value="true"/>
<!--
-->
</bean>
</beans>
<!-- END SNIPPET: example -->