RabbitMQ plugins

Overview

The RabbitMQ plugin connects QALIPSIS to the RabbitMQ broker.

Technology addressed

RabbitMQ: https://www.rabbitmq.com/

Dependency

io.qalipsis.plugin:qalipsis-plugin-rabbitmq

Namespace in scenario

rabbitmq()

Client library

RabbitMQ: refer to rabbitMQ

Supported steps
  • consume: polls data from the RabbitMQ broker.

  • produce: pushes data to the RabbitMQ broker.

An example scenario that uses a combination of the rabbitmq consume and produce steps is provided on GitHub.

Consume step

The consume step within the RabbitMQ plugin consumes data from queues of the RabbitMQ broker and forwards the data to the next step.

This step is generally used in conjunction with join to assert data or inject data into a workflow.

This step supports multithreading concurrent consumers using the concurrency() property. When the concurrency is set to more than 1, the sequence of the records transmitted to the next step in no longer guaranteed.

To learn more, visit the RabbitMQ website.

Ancestor

Scenario

Functionality

The consume step starts a polling loop for consumption of the designated queue. As new records appear, consume polls them and sends them to the next step.

Example
rabbitmq()
  .consume {
    name = "consume"
    connection {
      host = "localhost"
      port = 5672
      username = "Celia45"
      password = "Columbus1963"
    }
    queue(queueName = "battery_state")
}
Notable parameters
  • connection (required): configures the connection to the RabbitMQ broker; defaults to localhost:5672

  • queue (required): defines the name of the queue to consume.

  • concurrency (optional): defines the number of concurrent channels producing messages to RabbitMQ; defaults to 1.

  • prefetchCount(optional): defines the prefetch count value; defaults to 10.

  • broadcast (optional): specifies the broadcast parameters for the step.

Tip

Use the consume step with join to assert data or inject data into a workflow.

Reference documentation
  • Learn more about prefetchCount by reading the RabbitMQ Prefetch documentation.

  • To configure the consume step, consult the RabbitMQ documentation.

Produce step

The produce step within the RabbitMQ plugin provides messages to the RabbitMQ broker using a query; the messages are then forwarded as input to the next step.

Ancestor

Scenario

Functionality

The produce step’s input and step context are used to generate the values to complete the step; results are then forwarded to the next step(s).

Example
.rabbitmq()
.produce {
  connection {
    host = "localhost"
    port = 5672
      username = "Celia45"
      password = "Columbus1963"
  }
  records { _, input ->
    listOf(
      RabbitMqProducerRecord(
        exchange = "battery_state",
        routingKey = "battery_state",
        props = null,
        value = objectMapper.writeValueAsBytes(input)
      )
    )
  }
}
Notable parameters
  • concurrency(optional): defines the number of concurrent channels producing messages to RabbitMQ; defaults to 1.

  • connection: configures the connection to the RabbitMQ broker; defaults to localhost:5672.

  • records: configures and generates a list of produced records.

Reference documentation
  • For more information on configuring the connection to RabbitMQ, refer to Connecting to RabbitMQ.

  • For more information on configuring the produce step, refer to the RabbitMQ documentation.