All messages/responses received via a Receiver
are passed to a
Correlator
which notifies the correct SenderTask
. The
Correlator
component can extract a correlation ID from
both the requesnt and the response. It can also have an active role and actually create a
correlation ID and store it in the request message.
Correlator
is always bound to a Receiver
and does not make any
sense without it.
Example 4.27. An example of a correlator configuration
1 <receiver class="..." threads="..."> 2 <correlator class="..."> 3 ... 4 correlator properties 5 ... 6 </correlator> 7 <source>...</source> 8 ... 9 receiver properties 10 ... 11 </receiver>
When specifying the correlator class, unless you enter a fully classified class name,
the default package org.perfcake.message.correlator
is assumed.
In the following sections you can find a complete description of all correlators that can be used by PerfCake including all of their properties.
GenerateHeaderCorrelator
creates a new UUID style correlation
ID and stores it in a request message header and in message attributes. It then
searches for the same value in the response message headers. The header name used for storing
the UUID is perfcake.correlation.id
.
GenerateHeaderCorrelator
does not have any configurable properties.
Example 4.28. An example of GenerateHeaderCorrelator usage
1 <receiver class="HttpReceiver" threads="10"> 2 <correlator class="GenerateHeaderCorrelator" /> 3 <source>localhost:8080</source> 4 </receiver>
PrefixCorrelator
uses a message prefix - a string from the beginning of the message to a prefix boundary (:
by default) - as a correlation ID.
The prefix boundary can be configured via prefixBoundary
property of the correlator.
Following table shows the properties of the PrefixCorrelator:
Property name | Description | Required | Default value |
---|---|---|---|
prefixBoundary | A character or a string specifying the prefix boundary. | No | : |
Table 4.25. PrefixCorrelator properties
Example 4.29. An example of PrefixCorrelator usage
1 <receiver class="HttpReceiver" threads="10"> 2 <correlator class="PrefixCorrelator"> 3 <property name="prefixBoundary" value=":"/> 4 </correlator> 5 <source>localhost:8080</source> 6 </receiver>
In the example, when a message prefix-01:What is the meaning of life?
is sent through a sender,
the correlator extract the prefix prefix-01
according to the prefix boundary
:
and uses it as a correlation ID. The receiver then listens on HTTP address
http://localhost:8080
and waits for a response message with the same prefix
(e.g. prefix-01:I don't know, the computers are down.
).