4.5. What - Messages

A message is an actual payload, that is sent by a sender. To specify what will be sent, you can use the uri attribute of the particular message element in the scenario configuration. The uri can be an absolute file path in a form of file://... , URL or just a file name, in which case PerfCake will look for the file in the messages directory (See https://www.perfcake.org/quickstart/ ).

The simple payload of the message can be specified directly in the scenario by using content attribute instead of theuri. The value of the content attribute will be the actual message payload.

The scenario can be configured to send more that one message or to send a message more than once in a single iteration. To specify multiple different messages you just need to add more message elements in the messages configuration. To send a particular message more than once use the multiplicity attribute of the respective message element.

Example 4.30. An example of a simple message configuration:

  1    <messages>
  2       ...
  3       <message content="Greetings stranger!"/>
  4       ...
  5    </messages>

In the example above there is a single message defined. The payload of the message is the value of the content attribute .


Example 4.31. An example of multiple messages configuration:

  1    <messages>
  2       <message uri="message1.txt">
  3          <header name="header.name" value="header.value"/>
  4          <header name="header2" value="you-know"/>
  5          <property name="Empire.State.Building" value="A lot of $"/>
  6       </message>
  7       <message uri="message2.xml" multiplicity="2"/>
  8    </messages>

In the example above there are 2 messages defined. In the case of the first message the payload is taken from the file message1.txt and the message has two headers and one property specified. The second message is taken from the file message2.xml and will be sent two times in each iteration.


4.5.1. Filtering and templates

Messages stored in separate files can take an advantage of more complex filtering than those with body specified directly in the scenario file. This is optimized for performance. However, take into account that this might have a negative impact on the maximal message generation speed. It is recommended to create a comparative test without any templates to be sure there is no significant drop in troughput.

All system properties are must be prefixed with the props. namespace declaration. All environment properties must be prefixed with the env. namespace declaration. Internal PerfCake properties (i.e. message number) do not need any prefix. Sequences are accessible without any prefix, unless you defined with one.

While loading the message body from a file, all placeholders with the dollar sign are replaced first (for example${env.JAVA_HOME}). This is done only once and no later changes to the property values take any effect. There is an option to be able to replace a placeholder with a fresh property value each tima a new message is created/being sent. Such a property placeholder uses the at sign (for example@{props.counter}).

To specify a default value for a property, the double pipe character is used. For instance: ${property_name||default_value}

Any occurrence of the placeholder can be escaped using the backslash sign. This means that the following placeholders will never get replaced: \${non-replaceable} \@{ignored-placeholder}

For more details see Section 2.2.5, “Filtering properties”.