Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Chapter 33. DataSet
DataSet Component Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
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.
Apache Camel will use the throughput logger when sending dataset's.
URI format Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
dataset:name[?options]
dataset:name[?options]
Where name is used to find the DataSet instance in the Registry
Apache 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. Apache Camel also ships with some implementations that can be used for testing: the org.apache.camel.component.dataset.SimpleDataSet
, org.apache.camel.component.dataset.ListDataSet
, and org.apache.camel.component.dataset.FileDataSet
, all of which extend DataSetSupport
.
Options Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Option | Default | Description |
---|---|---|
produceDelay
|
3 | Allows a delay in ms to be specified, which causes producers to pause in order to simulate slow producers. Uses a minimum of 3 ms delay unless you set this option to -1 to force no delay at all. |
consumeDelay
|
0 | Allows a delay in ms to be specified, which causes consumers to pause in order to simulate slow consumers. |
preloadSize
|
0 | Sets how many messages should be preloaded (sent) before the route completes its initialization. |
initialDelay
|
1000 | Camel 2.1: Time period in millis to wait before starting sending messages. |
minRate
|
0 | Wait until the DataSet contains at least this number of messages |
dataSetIndex
|
lenient
|
Camel 2.17: Controls the behavior of the
CamelDataSetIndex header. The supported values are strict , lenient and off . The default behaviour prior to Camel 2.17 can be restored by setting dataSetIndex=strict .
For consumers:
For producers:
|
You can append query options to the URI in the following format,
?option=value&option=value&...
Configuring DataSet Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Apache 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>
<bean id="myDataSet" class="com.mycompany.MyDataSet">
<property name="size" value="100"/>
</bean>
Example Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
For example, to test that a set of messages are sent to a queue and then consumed from the queue without losing 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");
// 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 DataSetSupport Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Property
|
Type
|
Default
|
Description
|
---|---|---|---|
defaultHeaders
|
Map<String,Object>
|
null
|
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 .
|
outputTransformer
|
org.apache.camel.Processor
|
null
|
|
size
|
long
|
10
|
Specifies how many messages to send/consume.
|
reportCount
|
long
|
-1
|
Specifies the number of messages to be received before reporting progress. Useful for showing progress of a large load test. If < 0, then size / 5, if is 0 then size , else set to reportCount value.
|
SimpleDataSet Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The
SimpleDataSet
extends DataSetSupport
, and adds a default body.
Property
|
Type
|
Default
|
Description
|
---|---|---|---|
defaultBody
|
Object
|
<hello>world!</hello>
|
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 .
|
ListDataSet Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The List
DataSet
extends DataSetSupport
, and adds a list of default bodies.
Property
|
Type
|
Default
|
Description
|
---|---|---|---|
defaultBodies
|
Object
|
<hello>world!</hello>
|
|
size
|
long
|
10
|
|
FileDataSet Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The
SimpleDataSet
extends ListDataSet
, and adds support for loading the bodies from a file.
Property
|
Type
|
Default
|
Description
|
---|---|---|---|
sourceFile
|
String
|
null
|
|
delimiter
|
String
|
\z
|
|