Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
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 some implementations that can be used for testing:  

  • org.apache.camel.component.dataset.SimpleDataSet

...

  • org.apache.camel.component.dataset.ListDataSet

...


  • org.apache.camel.component.dataset.FileDataSet

, all of which extend DataSetSupport.

...

Div
classconfluenceTableSmall

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 of 3ms delay. Set 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 pre-loaded (sent) before the route completes its initialization.

initialDelay

1000

Camel 2.1: Time period in millis milliseconds to wait before starting sending messages.

minRate

0

Wait until the the DataSet contains at least this number of messages.

dataSetIndexlenient

Camel 2.17: Controls the behavior of the CamelDataSetIndex header.

The supported values are:

  • strict
  • lenient
  • off

The default behavior prior to Camel 2.17 can be restored using dataSetIndex=strict.

   
Client TypeDataSet Index ValuedataSetIndex ValueCamelDataSetIndex Header BehaviorDescription
Consumer

strictThe CamelDataSetIndex The header will always be set.
lenient
offThe CamelDataSetIndex The header will NOT be set.
Producer

strictThe CamelDataSetIndex The header must be present and the value of the header will be verified.
lenientIf the CamelDataSetIndex header is present, the value of the header will be verified. If the header is not present, it will be set. offIf the CamelDataSetIndex header is present, the value of the header will not be verified. If the header is not present, it will not be set.

 

For consumers:
- strict or lenient => The CamelDataSetIndex header will always be set
-
off
=> The CamelDataSetIndex header will not be set
For producers:
- strict => The CamelDataSetIndex header must be present and the value of the header will be verified
- lenient => If the CamelDataSetIndex header is present, the value of the header will be verified.
If the header is
not
present,
it will be set.
- off => If the CamelDataSetIndex header is present,
the value of the header will not be verified. If the header is not present, it will not be set.

You can append query options to the URI in the following format, : ?option=value&option=value&...

Configuring DataSet

Camel will lookup in the Registry for a bean implementing the the DataSet interface. So you can register your own own DataSet as:

Code Block
xml
xml
   <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 and then consumed from the queue without losing any messages:

Code Block
languagejava
// sendSend the dataset to a queue
from("dataset:foo")
  .to("activemq:SomeQueue");

// nowNow lets test that the messages are consumed correctly
from("activemq:SomeQueue")
  .to("dataset:foo");

The above would look in the Registry to find the 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.  

 

DataSetSupport (abstract class)

The The DataSetSupport abstract class is a nice starting point for new DataSets, and provides some useful features to derived classes.

Properties on on DataSetSupport

Div
classconfluenceTableSmall

Property

Type

Default

Description

defaultHeaders

Map<String,Object>

null

Specifies the default message body.

For  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.

reportCountlong-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

If == 0 then size

, else

 

Else set to reportCount value.

SimpleDataSet

The SimpleDataSet extends DataSetSupport, and adds a default body.

...

Div
classconfluenceTableSmall

Property

Type

Default

Description

defaultBody

Object

<hello>world!</hello>

Specifies the default message body. By default, the SimpleDataSet produces the same constant payload for each exchange. If you want to customize the payload for each exchange, create a Camel Processor and configure the SimpleDataSet to use it by setting the outputTransformer property.

ListDataSet (Camel 2.17)

The ListDataSet extends The ListDataSet extends DataSetSupport, and adds a list of default bodies.

...

Div
classconfluenceTableSmall

Property

Type

Default

Description

defaultBodies

List<Object>

empty LinkedList<Object>

Specifies the default message body. By default, the ListDataSet selects a constant payload from the list of defaultBodies using the CamelDataSetIndex. If you want to customize the payload, create a Camel Processor and configure the ListDataSet to use it by setting the outputTransformer property.

size

long

the size of the the defaultBodies list

Specifies how many messages to send/consume. This value can be different from the size of the defaultBodies list. If the value is less than the size of the defaultBodies list, some of the list elements will not be used. If the value is greater than the size of the defaultBodies list, the payload for the exchange will be selected using the modulus of the CamelDataSetIndex and the size of the defaultBodies list (i.e. CamelDataSetIndex % defaultBodies.size() )

FileDataSet (Camel 2.17)

The SimpleDataSet extends ListDataSet, and adds support for loading the bodies from a file.

Additional Properties on on FileDataSet

Div
classconfluenceTableSmall

Property

Type

Default

Description

sourceFile

File

null

Specifies the source file for payloads

delimiter

String

\z

Specifies the delimiter pattern used by a java.util.Scanner to split the file into multiple payloads.

...