RabbitMQ

Know the component and how to use it.

Micaella Mazoni avatar
Written by Micaella Mazoni
Updated over a week ago

IMPORTANT: This documentation has been discontinued. Read the updated RabbitMQ documentation on our new documentation portal.

RabbitMQ allows messages to be published in a RabbitMQ broker.

Take a look at the configuration parameters of the component:

  • Account: credential used to authenticate in RabbitMQ.

  • Hostname: name of the host that executes the RabbitMQ.

  • Port: connection port of the RabbitMQ (standard: 5672).

  • Connection Timeout: maximum time to connect to RabbitMQ.

  • Virtual Host: name of the logical group inside RabbitMQ to which there must be connection (standard /).

  • Exchange Name: name of the exchange defined in RabbitMQ which there're messages sent to.

  • Binary Message: if the option is activated, the message will be considered binary and the Message Body field must inform a string containing the base64 representation of the bytes set to be sent; otherwise, the message will be considered as text.

  • Message Body: content of the message to be sent.

  • Routing Key: string representing the relationship key between the Exchange and the Queue(s).

  • Headers: set of inputs "key": "value" containing headers that are sent in the message (optional field).

  • Message Type: string representing the type of message (optional field).

  • Message Content Type: string representing the content type of the message (eg.: application/json) (optional field).

  • Message Content Encoding: string representing the content coding (eg.: UTF-8) (optional field).

  • Priority: number indicating the priority of the message (optional field).

  • Correlation ID: string representing the correlation ID of the message (optional field).

  • Message ID: string representing the ID of the message (optional field).

  • Delivery Mode: if "Persistent Message", then the message is sent with the persistent flag and the broker will try to keep it in disk as soon as possible; if "Transient Message", then the broker will try to keep the message in memory.

  • Reply To: string representing the message return address (optional field).

  • Message Expiration: number representing the duration time of the message in the queue (also known as TTL) (optional field)

  • Message Timestamp: number representing the message timestamp (optional field).

  • Application Name: string representing the application name (optional field).

  • Fail On Error: if the option is enabled, the execution of the pipeline with error will be interrupted; otherwise, the pipeline execution proceeds, but the result will show a false value for the “success” property.

  • Wait for a Publish Acknowledgement: if the option is activated, the component will wait for a message publication confirmation; otherwise, the component will send the message and won't wait for a confirmation.

  • Publisher Acknowledgement Timeout: maximum time the component will wait for a message publication confirmation.

  • Mandatory Message: if the option is activated, the message is marked as mandatory and an error will be thrown if it can't be routed; otherwise, then no routing verification is made (the "Wait for a Publish Acknowledgement" option needs to be enabled).

IMPORTANT: the configuration parameters won't be defined in the message if their values are left in blank.

Example of request answer to RabbitMQ

<SAME MESSAGE INFORMED IN THE INPUT>

IMPORTANT: RabbitMQ doesn't change the message presented in its input, except in case of error.

Example of request answer to RabbitMQ with error

{
"success": false,
"message": "Could not publish message to RabbitMQ due to an error",
"error": "java.net.SocketTimeoutException: connect timed out"
}

  • success: “false” when the operation fails

  • message: message about the error

  • exception: information about the type of occurred

Messages flow

Input

The component accepts any input message, being able to use it through Double Braces.

Output

  • without error

<SAME MESSAGE INFORMED IN THE INPUT>

  • with error

{
"success": false,
"message": "Could not publish message to RabbitMQ due to an error",
"error": "java.net.SocketTimeoutException: connect timed out"
}

RabbitMQ in Action

A message is always sent through this component from the Exchange and Routing Key. The Exchange has a bind with a topic or queue and forwards the message from the Routing Key.

Sending a simple message

Input message:

{
"message": "test"
}

Configurations:

Hostname: <RABBITMQ HOSTNAME>

Port: <PORT> (pattern port: 5672)

Virtual Host: /

Exchange Name: <EXCHANGE NAME>

Binary Message: disabled

Message: {{ message.$ }}

Routing key: <ROUTING KEY>

Fail On Error: disabled

Result:

{
"message": "test"
}

Sending a simple binary message

Input message:

{
"message": "ewoJIm1lc3NhZ2UiOiAidGVzdCIKfQo="
}

Configurations:

Hostname: <RABBITMQ HOSTNAME>

Port: <PORT> (pattern port: 5672)

Virtual Host: /

Exchange Name: <EXCHANGE NAME>

Binary Message: enabled

Message: {{ message.message }}

Routing key: <ROUTING KEY>

Fail On Error: disabled

Result:

{
"message": "ewoJIm1lc3NhZ2UiOiAidGVzdCIKfQo="
}

Sending a message to a queue and the response will be returned to another specificated one (Direct Reply-To)

Input message:

{
"message": "test"
}

Configurations:

Hostname: <RABBITMQ HOSTNAME>

Port: <PORT> (pattern port: 5672)

Virtual Host: /

Exchange Name: <EXCHANGE NAME>

Binary Message: disabled

Message: {{ message.$ }}

Routing key: <ROUTING KEY>

Reply To: <REPLY TO>

Fail On Error: disabled

Result:

{
"message": "test"
}

Did this answer your question?