RabbitMQ

AMQP messaging solution ideal for IoT and client / server use cases

Overview

RabbitMQ is a lightweight and easy-to-deploy messaging platform that supports multiple messaging protocols. It can be configured in distributed and federated setups to meet high-scale and high-availability requirements.

Joule enables publishing to RabbitMQ queues, exchanges and topics, providing flexible event-driven architectures.

Additionally, the page highlights the usage of Joule to consume events via RabbitMQ messaging subscriptions.

Examples & DSL attributes

This example shows how to configure a RabbitMQ consumer that subscribes to specific event types using routing keys with a topic exchange.

The consumer listens for events related to quotes for specific stocks (IBM, MSFT and GOOG) from the marketQuotes exchange.

The events are deserialised from a StreamEvent JSON object into a Joule StreamEvent object using a custom parser.

rabbitConsumer:
  host: localhost
  exchange:
    name: marketQuotes
    type: TOPIC
  
  routing:
    keys:
      - NASDAQ.IBM
      - NASDAQ.MSFT
      - NASDAQ.GOOG
  
  deserializer:
    parser: 
      com.fractalworks.examples.banking.data.QuoteToStreamEventParser

Attributes schema

Attribute
Description
Data Type
Required

host

RabbitMQ server hostname or Ip address

String

Default: localhost

port

RabbitMQ server port, must be greater than 0

Integer

Default: 5672

username

User name

String

Default: guest

password

password

String

Default: guest

virtualHost

Creates a logical group of connections, exchanges, queues, bindings, user permissions, etc. within an instance

String

Default: /

autoAck

Flag to consider if server should message acknowledged once messages have been delivered. False will provide explicit message acknowledgment

Boolean

Default: true

prefetchCount

QoS -maximum number of messages that the server will deliver, 0 if unlimited

Integer

Default: 1

global

QoS - true if the settings should be applied to the entire channel rather than each consumer

Boolean

Default: true

durable

Set a durable queue (queue will survive a server restart)

Boolean

Default: true

autoDelete

Server deletes queue when not in use

Boolean

Default: true

exclusive

Exclusive queue to this connection

Boolean

Default: false

arguments

Additional queue properties

Map<String, Object>

Default: null

exchange

Exchange configuration

routing

Routing configuration

deserializer

Deserialisation configuration

Exchange attributes schema

Attribute
Description
Data Type
Required

name

Name of exchange

String

type

In RabbitMQ, messages are published to an exchange and depending on the type of exchange, the message gets routed to one or more queues

TOPIC, DIRECT, FANOUT, HEADERS

Default: TOPIC

arguments

Additional binding properties

Map<String, Object>

Default: null

Exchange example

rabbitConsumer:
    ...
    exchange:
        name: marketQuotes
        type: DIRECT

Routing attributes schema

Attribute
Description
Data Type
Required

keys

Valid key format examples: 'nasdaq.ibm', 'dept.inventory.bolts'.

There are two important special cases to define keys:

  • *(star) can be substituted for exactly one word

  • #(hash) can be substituted for zero or more words

String

Default: All

Constraints: Any number of dot separated words to a limit of 255 bytes

Routing example

This example will subscribe to all events that match the first component of the key 'NASDAQ'

rabbitConsumer:
    ...
    routing:
        keys:
          - NASDAQ.#

Additional resources

Further AMQP resources can be found on the following links:

Last updated