4.6. Sequences

Sequences are used to create a sequence of values that change for each sent message set (a set of messages are all the messages specified in a single scenario). Whenever a message set is to be sent, a current snapshot of all sequences is created. Then the values are replaced in the message template and are also passed to MessageSender.preSend() method in messageAttributes. The property names/keys correspond to the configured sequence id.

We suggest to configure your sequence ids with a unique prefix (like seq.) to avoid possible conflicts with another properties.

Possible usages of sequences are:

Example 4.32. An example of a Sequence configuration

  1    <sequences>
  2       <sequence id="..." class="...">
  3          ...
  4          sequence properties
  5          ...
  6       </sequence>
  7    </sequences>

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

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


4.6.1. PrimitiveNumberSequence

Just an ever increasing number sequence starting at 0. There are no properties available but provides high performance.

Example 4.33. An example of PrimitiveNumberSequence configuration

  1    <sequence id="mySequence" class="PrimitiveNumberSequence" />

4.6.2. NumberSequence

Long number sequence with the ability to specify boundaries, direction (increasing or decreasing) of the counter and the step size.

Following table shows the properties of NumberSequence:

Property nameDescriptionRequiredDefault value
startBeginning of the sequence counter.No0
endEnd of the sequence counter (when reached, the counter can start from start depending on the cycle property). With positive (negative) step, Long.MIN_VALUE (Long.MAX_VALUE) disables checking for reaching the end value. NoLong.MIN_VALUE
stepThe step of the counter, can be either positive or negative.No1
cycleThe counter starts from beginning when reaching end again. Otherwise the counter stays at the end value for the rest of the test.Notrue

Table 4.26. NumberSequence properties


Example 4.34. An example of NumberSequence configuration

  1    <sequence id="mySequence" class="NumberSequence">
  2       <property name="start" value="10" />
  3       <property name="end" value="0" />
  4       <property name="step" value="-2" />
  5    </sequence>

4.6.3. RandomSequence

This sequence generates random numbers in the given range <min, max). i.e. including the min value but not the max value.

Following table shows the properties of RandomSequence:

Property nameDescriptionRequiredDefault value
minLower boundary of the interval of random number (inclusive).No0
maxUpper boundary of the interval of random numbers (exclusive). No100

Table 4.27. RandomSequence properties


Example 4.35. An example of RandomSequence configuration

  1    <sequence id="mySequence" class="RandomSequence">
  2       <property name="min" value="10" />
  3       <property name="max" value="256" />
  4    </sequence>

4.6.4. RandomUuidSequence

This sequence generates random UUID identifiers. It has no configuration parameters. All UUIDs have the same format. Sample UUID is 259f1e8a-816e-4fa0-a5eb-15e2aefe57a6.

Example 4.36. An example of RandomUuidSequence configuration

  1    <sequence id="mySequence" class="RandomUuidSequence"/>

4.6.5. ThreadIdSequence

Returns the value of Thread.currentThread().getId(). No configuration properties are available.

Example 4.37. An example of ThreadIdSequence configuration

  1    <sequence id="mySequence" class="ThreadIdSequence" />

4.6.6. TimeStampSequence

Returns the value of System.currentTimeMillis(). No configuration properties are available.

Example 4.38. An example of TimeStampSequence configuration

  1    <sequence id="mySequence" class="TimeStampSequence" />

4.6.7. FileLinesSequence

Every single line in a given input file specifies a value of this sequence. Once the end of the file is hit, the sequence starts from beginning. The whole file is read in the memory in advance. Please make sure the file is of a reasonable size given your expectations and memory limits.

Following table shows the properties of FileLinesSequence:

Property nameDescriptionRequiredDefault value
fileUrlLocation of the file with sequence values.Yes-

Table 4.28. FileLinesSequence properties


Example 4.39. An example of FileLinesSequence configuration

  1    <sequence id="mySequence" class="FileLinesSequence">
  2       <property name="fileUrl" value="sequence-lines.txt" />
  3    </sequence>

4.6.8. FilesContentSequence

Every single line in a given input index file specifies another file with sequence value. Once the end of the index file is hit, the sequence starts from beginning. The content of individual files is cached by default. Please make sure the files are of a reasonable size given your expectations and memory limits.

Following table shows the properties of FilesContentSequence:

Property nameDescriptionRequiredDefault value
fileUrlLocation of the index file with references to files with sequence values.Yes-
cacheContentWhen true (the default value) the content of individual files is cached in memory.Notrue

Table 4.29. FilesContentSequence properties


Example 4.40. An example of FilesContentSequence configuration

  1    <sequence id="mySequence" class="FilesContentSequence">
  2       <property name="fileUrl" value="sequence-index.txt" />
  3    </sequence>