Queues Commands - TestlumFramework/Testlum GitHub Wiki

πŸ“‘ Message Brokers Commands

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.

Supported Message Brokers

🐘 Kafka Command

Kafka

πŸ“– Overview

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.

βš™οΈ Command: <kafka>

The <kafka> tag is used for sending and receiving messages with Kafka in your Testlum scenarios.

βš™οΈ Parameters

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

🧩 Send Command

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

πŸ§ͺ Example Usage β€” Send Command

<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>

🧩 Receive Command

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

πŸ§ͺ Example Usage β€” Receive Command

<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>

βœ… Tips:

  • Use correlationId to track specific messages across multiple requests.
  • For better message reliability, always validate the response using file or value.
  • Multiple queries can be sent within a single <kafka> tag for efficiency.

πŸ“¦ RabbitMQ Command

RabbitMQ

πŸ“– Overview

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.

βš™οΈ Command: <rabbit>

The <rabbit> tag is used to send and receive messages with RabbitMQ in your Testlum scenarios.

βš™οΈ Parameters

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)

🧩 Send Command

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

πŸ§ͺ Example Usage β€” Send Command

<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>

🧩 Receive Command

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

πŸ§ͺ Example Usage β€” Receive Command

<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>

βœ… Tips:

  • Use routingKey to specify message routing in RabbitMQ.
  • Set a reasonable timeoutMillis for your receive command to avoid unnecessary delays.
  • Include prefetchCount to control how many messages the receiver can fetch at once.

πŸ“¬ SQS Command

SQS

πŸ“– Overview

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.

βš™οΈ Command: <sqs>

The <sqs> tag is used for sending and receiving messages in SQS queues.

βš™οΈ Parameters

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)

🧩 Send Command

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

πŸ§ͺ Example Usage β€” Send Command

<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>

🧩 Receive Command

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

πŸ§ͺ Example Usage β€” Receive Command

<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>

βœ… Tips:

  • 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.
⚠️ **GitHub.com Fallback** ⚠️