06 - Interservice Bus
Design Diagram
The Interservice Bus provides the means for the exchange of data in the decoupled architecture. RabbitMQ (https://www.rabbitmq.com/) is the open source message broker used. Through a direct exchange, RabbitMQ routes each message type to its own queue. Consumers then connect to the queue containing the messages they are designed to operate on.
Key Concept: Best Practices for ISB - Service interaction
Below is a list of practices to be implemented when interacting with the ISB:
- Use separate connections for consumers and producers.
- Set a logical prefetch count (often 1) that reflects the number of messages the service is allowed to work on at any one time.
- Only "Acknowledge" a message after the work it has requested is accomplished. In other words, if something fails mid-process, you want the message to be re-queued and tried again.
- Only "Reject" messages if they are intrinsically un-processable.
- Note that dependent resource availability should cause a re-queue, NOT a reject.
- Use durable queues and publisher confirms.
- Consumers and Producers are both responsible for queue creation.
- Producers are additionally responsible for routing key bindings.