RabbitMQ Plugin
The plugin provides the ability to publish messages to RabbitMQ and read them from a queue.
Installation
-
Copy the below line to
dependenciessection of the projectbuild.gradlefilePlease make sure to use the same version for all VIVIDUS dependencies. Example 1. build.gradleimplementation('org.vividus:vividus-plugin-rabbitmq') -
If the project was imported to the IDE before adding new dependency, re-generate the configuration files for the used IDE and then refresh the project in the used IDE.
Properties
Define one property group per connection. Pick a broker key (the first segment after rabbitmq.); use the same name as $brokerKey in the steps.
| The broker key must not contain dots. |
| Property name | Acceptable values | Default | Description |
|---|---|---|---|
|
hostname or IP |
|
The broker host. |
|
port number |
5671 |
The broker port. |
|
string |
The username. |
|
|
string |
The password. |
|
|
string |
The logical broker namespace (vhost) for connections, exchanges, and queues. |
rabbitmq.local.host=localhost
rabbitmq.local.port=5672
rabbitmq.local.username=guest
rabbitmq.local.password=guest
rabbitmq.local.virtual-host=/
rabbitmq.cloudamqp.host=penguin.lmq.cloudamqp.com
rabbitmq.cloudamqp.port=5672
rabbitmq.cloudamqp.username=bob
rabbitmq.cloudamqp.password=023fc15b9733b17df187
rabbitmq.cloudamqp.virtual-host=bob
Steps
Publish message
Sends the message text to the broker. The routing key is usually the queue name when you publish straight to a queue.
When I publish message `$message` with routing key `$routingKey` to RabbitMQ broker `$brokerKey`
-
$message- The message body. -
$routingKey- The routing key (often the queue name). -
$brokerKey- The broker key from the properties.
When I publish message `hello` with routing key `my-queue` to RabbitMQ broker `cloudamqp`
Retrieve message
Waits up to the timeout for one message on the given queue, stores the payload in a variable as text.
When I retrieve message from queue `$queue` of RabbitMQ broker `$brokerKey` with `$timeout` timeout and save it to $scopes variable `$variableName`
-
$queue- The queue to read from. -
$brokerKey- The broker key from the properties. -
$timeout- The maximum wait time in ISO-8601 Durations format to wait for a message. -
$scopes- The comma-separated set of variable scopes. -
$variableName- Where to store the message body.
When I retrieve message from queue `orders.queue` of RabbitMQ broker `local` with `PT10S` timeout and save it to SCENARIO variable `last-order`
Then `${last-order}` is equal to `order-123`