Queues Commands - TestlumFramework/Testlum GitHub Wiki
Testlum provides seamless integration with various message brokers such as Kafka, RabbitMQ, and SQS.
These brokers help manage message queues and enable communication between different systems in your architecture.
Kafka
Description:
Kafka is an open-source distributed streaming platform used for handling real-time data feeds. It is ideal for building scalable, fault-tolerant, and high-performance data pipelines, particularly in event-driven architectures.
The <kafka>
tag is used for sending and receiving messages with Kafka in your Testlum scenarios.
Parameter | Type | Required | Description |
---|---|---|---|
comment |
String | β | Description of the Kafka action |
alias |
String | β | Unique alias for the Kafka configuration in integration.xml
|
commands |
send or receive
|
β | Defines whether to send or receive a Kafka message |
condition |
Boolean | β | Condition to determine when the step will be executed |
threshold |
Integer (ms) | β | Maximum allowed execution time for this step |
The send
command is used to send a message to Kafka.
Parameter | Required | Description |
---|---|---|
topic |
β | The target Kafka topic to send the message to |
correlationId |
β | A unique identifier for tracking the message |
value |
β | The actual payload content of the message |
key |
β | A key associated with the message |
headers |
β | Additional metadata for the message |
file |
β | A file containing the message content |
<kafka comment="Send a message" alias="KAFKA_0"> <send topic="weather" correlationId="1"> <value> [ "city": "Houston" ] </value> <key>7</key> <headers> <header name="Lviv" value="20"/> <header name="Odesa" value="25"/> </headers> </send> <send topic="weather" correlationId="1"> <file>body_1.json</file> </send> </kafka>
The receive
command is used to receive a message from Kafka.
Parameter | Required | Description |
---|---|---|
topic |
β | The topic from which to receive the message |
timeoutMillis |
β | Maximum wait time (in ms) for the message to be received |
commit |
β | Whether to commit the message after itβs received (true or false ) |
headers |
β | Whether to include message headers (true or false ) |
file |
β | A file for expected results validation |
value |
β | Define the content of the received Kafka message |
<kafka comment="Receive 1 time" alias="KAFKA_0"> <receive topic="hundred" timeoutMillis="5000" commit="true" headers="false"> <file>expected_226.json</file> </receive> <receive topic="hundred" timeoutMillis="5000" commit="true" headers="false"> <value> [ "city": "Houston" ] </value> </receive> </kafka>
- Use
correlationId
to track specific messages across multiple requests.- For better message reliability, always validate the response using
file
orvalue
.- Multiple queries can be sent within a single
<kafka>
tag for efficiency.
RabbitMQ
Description:
RabbitMQ is a message broker software that provides a messaging queue for handling communication between various services in a distributed system. It enables asynchronous communication, allowing producers to send messages to queues and consumers to process them when ready.
The <rabbit>
tag is used to send and receive messages with RabbitMQ in your Testlum scenarios.
Parameter | Type | Required | Description |
---|---|---|---|
comment |
String | β | Description of the RabbitMQ action |
alias |
String | β | Unique alias for the RabbitMQ connection in integration.xml
|
commands |
send or receive
|
β | Choose between sending or receiving a message |
condition |
Boolean | β | Optional condition for executing the test step |
threshold |
Integer (ms) | β | Maximum allowed execution time for this step (in milliseconds) |
The send
command is used to send a message to RabbitMQ.
Parameter | Required | Description |
---|---|---|
routingKey |
β | The routing key for message delivery |
correlationId |
β | A unique identifier for the message |
exchange |
β | An identifier for the RabbitMQ exchange |
body |
β | The content or payload of the message |
headers |
β | Additional metadata or attributes for the message |
file |
β | A file containing the message content |
<rabbit comment="Send a command" alias="RABBIT_0"> <send routingKey="out" correlationId="5" exchange="1"> <body> [ "city": "Houston" ] </body> <headers> <header name="Lviv" value="20"/> <header name="Odesa" value="25"/> </headers> </send> <send routingKey="in"> <file>body_8.json</file> </send> </rabbit>
The receive
command is used to receive a message from RabbitMQ.
Parameter | Required | Description |
---|---|---|
queue |
β | The queue from which to receive the message |
timeoutMillis |
β | Timeout for waiting for the message (in milliseconds) |
headers |
β | Whether to include message headers |
prefetchCount |
β | Maximum number of unacknowledged messages to prefetch |
message |
β | The content or payload of the received message |
file |
β | A file to compare the received message with |
<rabbit comment="Receive a command" alias="RABBIT_0"> <receive queue="weather" timeoutMillis="2000" headers="true" prefetchCount="2"> <message> [ "city": "Houston" ] </message> </receive> <receive queue="weather"> <message> <file>expected_223.json</file> </message> </receive> </rabbit>
- Use
routingKey
to specify message routing in RabbitMQ.- Set a reasonable
timeoutMillis
for yourreceive
command to avoid unnecessary delays.- Include
prefetchCount
to control how many messages the receiver can fetch at once.
SQS
Description:
Amazon SQS (Simple Queue Service) is a fully managed message queuing service that enables communication between software components, microservices, and distributed systems. It helps ensure reliable and scalable message delivery without losing messages, even when other services are unavailable.
The <sqs>
tag is used for sending and receiving messages in SQS queues.
Parameter | Type | Required | Description |
---|---|---|---|
comment |
String | β | Description of the SQS action |
alias |
String | β | Unique alias for the SQS integration in integration.xml
|
commands |
send or receive
|
β | Defines whether to send or receive messages from the SQS queue |
condition |
Boolean | β | Optional condition for executing the step |
threshold |
Integer (ms) | β | Maximum allowed execution time for this step (in milliseconds) |
The send
command is used to send a message to an SQS queue.
Parameter | Required | Description |
---|---|---|
queue |
β | The name of the queue where the message will be sent |
delaySeconds |
β | Delay in seconds before the message becomes available (min: 1) |
messageDeduplicationId |
β | Unique ID for message deduplication |
messageGroupId |
β | Used for message grouping in FIFO queues |
value |
β | Content or payload of the message |
file |
β | File containing the message content |
<sqs comment="Check ability to create queue and send first text message and json file" alias="SQS_0"> <send queue="queue1" delaySeconds="5" messageDeduplicationId="1" messageGroupId="1"> <value>Hello World!</value> </send> <send queue="queue1" delaySeconds="5"> <file>body_5.json</file> </send> </sqs>
The receive
command is used to receive a message from an SQS queue.
Parameter | Required | Description |
---|---|---|
queue |
β | The name of the queue from which to receive the message |
receiveRequestAttemptId |
β | Unique identifier for the receive request attempt |
maxNumberOfMessages |
β | The maximum number of messages to receive in one operation |
visibilityTimeout |
β | Time during which the message is invisible to other consumers |
waitTimeSeconds |
β | Maximum wait time (in seconds) for the message to become available |
message |
β | Structure and content of the received message |
file |
β | A file containing the expected results of the received message |
<sqs comment="Check ability to receive messages" alias="SQS_0"> <receive queue="queue1"> <file>expected_10.json</file> </receive> <receive queue="queue1" receiveRequestAttemptId="1" maxNumberOfMessages="1" visibilityTimeout="1" waitTimeSeconds="1"> <value> [ "Hello World!" ] </value> </receive> </sqs>
- Use
messageDeduplicationId
for ensuring only one copy of a message is processed.- Set
visibilityTimeout
to prevent other consumers from processing a message after it's been received.waitTimeSeconds
can optimize message retrieval time in low-traffic queues.