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 consume events using RabbitMQ messaging subscription

Configuration Guide

Example configuration

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

This example configures a RabbitMQ consumer to receive three event types using the routing keys elements from the topic exchange type. Quote events are deserialised from a StreamEvent Json object to a Joule StreamEvent object.

Core Attributes

Available configuration parameters

Exchange Attributes

Exchange example

exchange:
    name: marketQuotes
    type: DIRECT

Routing Attributes

Routing example

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

  routing:
    keys:
      - NASDAQ.#

Deserialization Attributes

This topic provides configuration parameters available object deserialization process.

Deserializer example

deserializer:
  transform: com.fractalworks.streams.examples.banking.data.QuoteToStreamEventTransformer
  compressed: false

Examples

All examples assume default values when not applied.

Queue based eventing

Sets up a simple consumer which subscribes to events directly off of a queue.

rabbitConsumer:
  queue: point_to_point_queue
  deserializer:
    transform: com.fractalworks.streams.transport.serializers.QuoteToStreamEventTransformer

Work Queues

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

rabbitConsumer:
  queue: worker_queue
  autoAck: false
  durable: true
  prefetchCount: 1

  deserializer:
    transform: com.fractalworks.streams.transport.serializers.QuoteToStreamEventTransformer

Publish/Subscribe

This example each consumer process will receive the same message. Because the exchange is configured as a fanout we do not need to use the routing element, this will be covered in the next example

rabbitConsumer:
  exchange:
    name: quotes_exchange
    type: FANOUT

  deserializer:
    transform: com.fractalworks.streams.transport.serializers.QuoteToStreamEventTransformer

Routing

This time we're going to make it possible to subscribe only to a subset of the messages for a single consumer. Therefore each Joule consumer process will have its own routing keys they would subscribe to. In the case below a process using this configuration will only receive IBM and MSFT quotes.

rabbitConsumer:
  host: localhost
  exchange:
    name: quotes_exchange
    type: DIRECT

  routing:
    keys:
      - NASDAQ.IBM
      - NASDAQ.MSFT

  deserializer:
    transform: com.fractalworks.streams.transport.serializers.QuoteToStreamEventTransformer

Topic

This example is very similar to the previous case whereby we subscribe to events that we are interested in. However, we are using a topic exchange that enabled us to use the dot notation and wildcards to subscribe to a wider set of events. In the case below we would receive all market venue quotes for both IBM and MSFT.

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

  routing:
    keys:
      - "*.IBM"
      - "*.MSFT"

  deserializer:
    transform: com.fractalworks.streams.transport.serializers.QuoteToStreamEventTransformer

Client library

com.rabbitmq:amqp-client:5.16.0

Additional Resources

Last updated