AMQP steps
This plugin provides a set of steps to interact with AMQP brokers via the Advanced Message Queuing Protocol. It supports AMQP 1.0 and AMQP 0.9.1 connections, configurable queue declarations and message persistence, plus steps to send and assert JSON messages, purge queues, and validate that no messages are received.
Install
Include the module in the corresponding section.
es.iti.wakamiti:amqp-wakamiti-plugin:2.8.0
es.iti.wakamiti:amqp-wakamiti-plugin:2.8.0
<dependency> <groupId>es.iti.wakamiti</groupId> <artifactId>amqp-wakamiti-plugin</artifactId> <version>2.8.0</version> </dependency>
<dependency> <groupId>es.iti.wakamiti</groupId> <artifactId>amqp-wakamiti-plugin</artifactId> <version>2.8.0</version> </dependency>
Options
amqp.connection.url
- Type:
stringrequired
Sets the URL to be used by the AMQP broker.
Example:
amqp: connection: url: amqp://127.0.0.1:5671
amqp.connection.username
- Type:
stringrequired
Sets the username to be used by the AMQP broker.
Example:
amqp: connection: username: guest
amqp.connection.password
- Type:
stringrequired
Sets the password to be used by the AMQP broker.
Example:
amqp: connection: password: guest
amqp.connection.protocol
- Type:
string - Default
AMQP_1_0
Selects the AMQP wire protocol to use. Accepted values include AMQP_1_0 and AMQP_0_9_1 (aliases such as
amqp-1.0, amqp-0.9.1, 1_0, 0_9_1 are also supported).
Example:
amqp: connection: protocol: AMQP_0_9_1
amqp.message.persistent
- Type:
boolean - Default
true
Sets whether messages are sent as persistent.
Example:
amqp: message: persistent: "false"
amqp.queue.durable
- Type:
boolean - Default
false
Sets whether the queue will be durable or not (the queue will survive a server reboot).
Example:
amqp: queue: durable: "true"
amqp.queue.exclusive
- Type:
boolean - Default
false
Sets whether the queue will be exclusive (restricted to the current connection).
Example:
amqp: queue: exclusive: "true"
amqp.queue.autodelete
- Type:
boolean - Default
false
Sets whether to auto delete queue (will be deleted by server when no longer in use).
Example:
amqp: queue: autodelete: "true"
Steps
Define connection
the AMQP connection URL {url} using the user {username} and the password {password}the AMQP connection URL {url} using the user {username} and the password {password}Sets the URL and credentials to be used by the AMQP broker. This is the descriptive way of setting the configuration
properties amqp.connection.url, amqp.connection.username,
amqp.connection.password.
Parameters
| Name | Wakamiti type | Description |
|---|---|---|
url |
text required |
The broker URL |
username |
text required |
The credentials username |
password |
text required |
The credentials password |
Examples:
Given the AMQP connection URL 'amqp://127.0.0.1:5671' using the user 'guest' and the password 'guest'
Define protocol
the AMQP protocol {protocol}the AMQP protocol {protocol}Defines the AMQP protocol to use. This is the descriptive way of setting the configuration property
amqp.connection.protocol.
Parameters
| Name | Wakamiti type | Description |
|---|---|---|
protocol |
word required |
The protocol name |
Examples:
Given the AMQP protocol AMQP_0_9_1
Define destination queue
the destination queue {word}the destination queue {word}Sets the name of the queue to watch.
Parameters
| Name | Wakamiti type | Description |
|---|---|---|
word |
word required |
A queue name |
Examples:
Given the destination queue TESTPurge queue
(that) the queue {word} is emptied(that) the queue {word} is emptiedPurges all pending messages from the given queue.
Parameters
| Name | Wakamiti type | Description |
|---|---|---|
word |
word required |
A queue name |
Examples:
When the queue TEST is emptied
Send message to queue
the following JSON message is sent to the queue {word}:
{data}the following JSON message is sent to the queue {word}:
{data}Sends a JSON message to the given queue.
Parameters
| Name | Wakamiti type | Description |
|---|---|---|
word |
word required |
A queue name |
data |
document required |
A JSON message body |
Examples:
When the following JSON message is sent to the queue TEST:
"""json
{
"data": {
"message": "Test message sent"
}
}
"""Send message to queue (file)
the message from the JSON file {file} is sent to the queue {queue}the message from the JSON file {file} is sent to the queue {queue}Sends a JSON message extracted from a local file to the given queue.
Parameters
| Name | Wakamiti type | Description |
|---|---|---|
file |
file required |
A local file with the JSON message |
queue |
word required |
A queue name |
Examples:
When the message from the JSON file 'data/message.json' is sent to the queue TEST
Set pause
wait for {duration}wait for {duration}Waits a fixed duration (usually to ensure a message has been processed).
Parameters
| Name | Wakamiti type | Description |
|---|---|---|
duration |
duration required | Amount of time |
Examples:
* Wait for 2 seconds
Validate message
the following JSON message is received within {duration}:
{data}the following JSON message is received within {duration}:
{data}Validates that a specific JSON message is received in the destination queue, failing after a certain timeout.
Parameters
| Name | Wakamiti type | Description |
|---|---|---|
duration |
duration required | Amount of time |
data |
document required |
A JSON message body |
Examples:
Then the following JSON message is received within 5 seconds:
"""json
{
"data": {
"message": "Test message sent"
}
}
"""Validate message (file)
the message from the JSON file {file} is received within {duration}the message from the JSON file {file} is received within {duration}Validates that a specific JSON message is received in the destination queue, failing after a certain timeout.
Parameters
| Name | Wakamiti type | Description |
|---|---|---|
file |
file required |
A local file with the JSON message |
duration |
duration required | Amount of time |
Examples:
Then the message from the JSON file 'data/message.json' is received within 5 secondsValidate no message
no message is received within {duration}no message is received within {duration}Validates that no message is received in the destination queue within the timeout window.
Parameters
| Name | Wakamiti type | Description |
|---|---|---|
duration |
duration required | Amount of time |
Examples:
Then no message is received within 10 seconds
Special modes
Some steps may be executed with a different behavior if they are defined in the following ways:
Post-execution mode
On completion, *
On completion, *
The step shall be executed once the scenario has finished, regardless of the outcome of the execution.
Examples:
* On completion, the queue TEST is emptied