Bus event handling
Under Construction
This page is still under construction and is not available yet.
Please reach out on Discord if you have some questions about the Bus events
Architecture
Infrahub requires the following features from the message bus:
- Retry messages with a delay
- Broadcast messages to multiple consumers
- Asynchronous RPC
- Set priorities to messages
Depending on the message bus system, we implement them using the following:
RabbitMQ
- We create a
delayedexchange and multiple queues per TTL variation. When there is an error on message processing, the worker will publish the failed message in the delayed exchange with the delay TTL set. Note: for non-acked (NAK, expired, dropped, or lost) messages, we make use of a dead-letter exchange (DLX). Note bis: events and callback messages do not require acknowledgment. - We create one
eventsqueue per worker binding on the required broadcast messages using their routing keys. - Requests are sent to the exchange and processed by an unique queue where each worker consume messages.
We also create one
callbackqueue per worker and use thereply-toheader to send reply messages to this queue. - Priorities are handled using the
priorityfield of message properties.
NATS JetStream
- We NAK the message with a delay.
- We create an
eventsstream with retention policy set toINTERESTand create an ephemeral consumer for each worker. - Requests are sent to the
rpcsstream with retention policy set toWORK_QUEUEand create a consumer group on which each worker will subscribe. We also create onecallbackstream per worker and publish to this stream for the replies. - We do not handle priorities.