AMQP steps

This plugin provides a set of steps to interact with an application via the Advanced Message Queuing Protocol. The underlying implementation is based on RabbitMQ, although it might change in further versions.

DISCLAIMER

Currently, this library provides very limited functionality and exists mostly as a proof of concept.



Install

Include the module in the corresponding section.

es.iti.wakamiti:amqp-wakamiti-plugin:2.4.0
<dependency>
  <groupId>es.iti.wakamiti</groupId>
  <artifactId>amqp-wakamiti-plugin</artifactId>
  <version>2.4.0</version>
</dependency>

Options

amqp.connection.url

  • Type: string required

Sets the URL to be used by the AMQP broker.

Example:

amqp:
  connection:
    url: amqp://127.0.0.1:5671

amqp.connection.username

  • Type: string required

Sets the username to be used by the AMQP broker.

Example:

amqp:
  connection:
    username: guest

amqp.connection.password

  • Type: string required

Sets the password to be used by the AMQP broker.

Example:

amqp:
  connection:
    password: guest

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}

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

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 TEST


Send message to queue

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}

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 {integer} second(s)

Waits a fixed number of seconds (usually to ensure a message has been processed).

Parameters

Name Wakamiti type Description
integer integer required Amount of time (in seconds)

Examples:

* Wait for 2 seconds

Validate message

the following JSON message is received within {integer} seconds:
    {data}

Validates that a specific JSON message is received in the destination queue, failing after a certain timeout.

Parameters

Name Wakamiti type Description
integer integer required Amount of time (in seconds)
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 {seconds} seconds

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
seconds integer required Amount of time (in seconds)

Examples:

Then the message from the JSON file 'data/message.json' is received within 5 seconds