4.3. Receiving messages

A Receiver is a component used to receive responses from a separate message channel. It is though possible to send requests to some protocol and use a completely different protocol to receive responses.

The Receiver always needs to know how many threads it should use to receive responses and from where it should read them. So there is a mandatory attribute threads, and two mandatory tags source and correlator. For Correlators see Section 4.4, “Correlating messages”.

Some Senders allow generating requests without specifying a message in the scenario. However, this does not work with Receivers and Correlators. There always needs to be a message specified (be it a message with an empty body) for the Correlator to be able to compute (and possibly store) the correlation ID. PerfCake insists on user specifying the message for them to realize the configuration is different (in other words, PerfCake does not perform any magic hidden operations on your configuration).

Example 4.25. An example of a Receiver configuration

  1    <receiver class="..." threads="...">
  2       <correlator class="..." />
  3       <source>...</source>
  4       ...
  5       receiver properties
  6       ...
  7    </receiver>

When specifying the receiver class, unless you enter a fully classified class name, the default package org.perfcake.message.receiver is assumed.

In the following sections you can find a complete description of all Receivers that can be used by PerfCake including all of their properties.

4.3.1. HttpReceiver

The HttpReceiver can be used to receive responses from an HTTP channel. It opens an HTTP port and listens for responses. After receiving a single response it immediatelly cresponds with the given response, status code and status message.

Following table shows the properties of the HttpReceiver:

Property nameDescriptionRequiredDefault value
source<address>[:<port>] where to bind the HTTP server and listen for the messages. The default port, if not specified, is 8088. Please note that for lower port numbers you might need to run PerfCake as a superuser (root, administrator).Yes-
httpStatusCodeThe HTTP status code to return to the client sending the message.No200
httpStatusMessageA status message to return to the client sending the message. By default, no status message is set.No-
httpResponseA response to return to the client sending the message. By default, no response is sent.No-

Table 4.24. HttpReceiver properties

Example 4.26. An example of HttpReceiver configuration

  1    <receiver class="HttpReceiver" threads="100">
  2       <correlator class="GenerateHeaderCorrelator" />
  3       <source>localhost:3000</source>
  4       <property name="httpResponse" value="Hello this is PerfCake!"/>
  5    </receiver>