RabbitMQ

RabbitMQ is lightweight and easy to deploy messaging platform. It supports multiple messaging protocols. RabbitMQ can be deployed in distributed and federated configurations to meet high-scale, high-availability requirements. Joule provides the ability to publish to RabbitMQ queues, exchanges and topics.

Driver details

com.rabbitmq:amqp-client:5.16.0

Configuration Guide

Example configuration

rabbitPublisher:
  queue: quotes_queue

  serializer:
    formatter:
      jsonFormatter:
        encoding: UTF-8

This will publish StreamEvents as JSON formatted messages onto the quotes_queue.

Core Attributes

Available configuration parameters

Exchange Attributes

Exchange example

exchange:
    name: marketQuotes
    type: TOPIC

Routing Attributes

Routing example

This example will dynamical create route binding using the market and symbol StreamEvent fields. As an example the following would be created nasdaq.IBM as a routing key.

  routing:
    event fields:
      - market
      - symbol

Serialization Attributes

This topic provides configuration parameters available object serialization process.

Serializer example

serializer:
  formatter:
    jsonFormatter:
      encoding: UTF-8

Examples

All examples assume default values when not applied.

Queue based eventing

Sets up a simple publisher which sends to Json StreamEvents directly to a named queue.

rabbitPublisher:
  queue: quote_queue

  serializer:
    formatter:
      jsonFormatter:
        encoding: UTF-8

Work Queues

Publish to a Worker Queue that is used to distribute time-consuming tasks among multiple Joule workers.

rabbitPublisher:
  queue: quote_queue
  messageExpiration: 5000

  serializer:
    formatter:
      jsonFormatter:
        encoding: UTF-8

Publish/Subscribe

This example publishes events to an exchange where consumers receive these events from a connected exchange queue. Because the exchange is configured we do not need to define a queue name.

rabbitPublisher:
  exchange:
    name: quotes_exchange
    type: FANOUT

  serializer:
    formatter:
      jsonFormatter:
        encoding: UTF-8

Routing

This time we're going to make it possible to publish events using routing keys so that consumers can selectively subscribe to required events.

rabbitPublisher:
  host: localhost
  exchange:
    name: quotes_exchange
    type: TOPIC

  routing:
    event fields:
      - market
      - symbol

  serializer:
    formatter:
      jsonFormatter:
        encoding: UTF-8

Topic

This example is very similar to the previous case whereby we publish to events using routing keys. However, since we are using a topic exchange this enables the consuming client to use wildcards to subscribe to a wider set of events, see RabbitMQ source documentation for further information.

rabbitPublisher:
  host: localhost
  exchange:
    name: quotes_exchange
    type: TOPIC

  routing:
    event fields:
      - market
      - symbol

  serializer:
    formatter:
      jsonFormatter:
        encoding: UTF-8

Additional Resources

Last updated