DataSet Component
The DataSet component (available since 1.3.0) provides a mechanism to easily perform load & soak testing of your system. It works by allowing you to create DataSet instances both as a source of messages and as a way to assert that the data set is received.
URI format
dataset:name?options
Where name is used to find the DataSet instance in the Registry
Camel ships with a support implementation of org.apache.camel.component.dataset.DataSet
, the org.apache.camel.component.dataset.DataSetSupport
class, that can be used as a base for implementing your own DataSet. Camel also ships with a default implementation, the org.apache.camel.component.dataset.SimpleDataSet
that can be used for testing.
Options
Option |
Default |
Description |
---|---|---|
produceDelay |
-1 |
Allows a delay to be specified which causes producers to pause - to simulate slow producers |
consumeDelay |
-1 |
Allows a delay to be specified which causes consumers to pause - to simulate slow consumers |
preloadSize |
0 |
Sets how many messages should be preloaded (sent) before the route completes its initialization |
Configuring DataSet
Camel will lookup in the Registry for a bean implementing the DataSet interface. So you can register your own DataSet as:
<bean id="myDataSet" class="com.mycompany.MyDataSet"> <property name="size" value="100"/> </bean>
Example
For example to test that a set of messages are sent to a queue then consumed from a queue without loosing any messages.
// send the dataset to a queue from("dataset:foo").to("activemq:SomeQueue"); // now lets test that the messages are consumed correctly from("activemq:SomeQueue").to("dataset:foo");
The above would look in the Registry to find the foo DataSet instance which is used to create the messages.
Then you create a DataSet implementation, such as using the SimpleDataSet
as described below, configuring things like how big the data set is and what the messages look like etc.
Properties on SimpleDataSet
Property |
Type |
Description |
---|---|---|
defaultBody |
Object |
Specifies the default message body. For SimpleDataSet it is a constant payload; though if you want to create custom payloads per message create your own derivation of DataSetSupport |
reportGroup |
long |
Specifies the number of messages to be received before reporting progress. Useful for showing progress of a large load test |
size |
long |
Specifies how many messages to send/consume |
Load testing ActiveMQ with Camel
There is an example of load testing an ActiveMQ queue using Camel in the ActiveMQ source code repository. The code lives at this location
You can grab the code
svn co https://svn.apache.org/repos/asf/activemq/trunk/activemq-camel-loadtest/
Then try running the test case
cd activemq-camel-loadtest mvn clean install
To see how the test is defined see the Spring XML file