[Course] RabbitMQ by Example
RabbitMQ is used to produce synchronous and asynchronous systems.
Introducing RabbitMQ
Compared with other Messaging Systems:
- RabbitMQ is a distributed system, others are centralized.
- RabbitMQ plays into a Clustered environment for high availability.
- RabbitMQ is multiplatform, and MSMQ is Windows only.
- RabbitMQ is a standard-based but MSMQ not.
Also RabbitMQ is multiplatform and there are MQ clients for several programming languages.
Introducing RabbitMQ Exchanges
What is AMQP Protocol
It is Advanced Messaging Queueing Protocol. It is a standard. Rabbit supports 0.9.1. It also supports AMQP 1.0.
Also,
What about AMQP 2.0
Here.
Understanding Queueing Architecture
Compared with other Messaging Systems:
Desired Properties
- Durability: inmemory o database
- Security Policies: access control
- Messaging Purging: time to live
- Messages filtering:
- Deliver Policies: guaranteed to deliver
- Routing Policies: which receives messages
- Batching Policies: to deliver one inmmediately or many messages at time
- Queueing Criteria: which could get requeue
- Receipt Notification: notify if consumers have received the message
Common Use Cases for Messaging
- Decoupling. To allow integration between applications implementing a layer and allowing the applications to grow in a separate way independiently.
- Redundancy. For the cases when processes failed, the solution is to have persisted data in the middle to allow reprocessing.
- Scalability. Messaging systems decouple the processes. Adding more processes to a backend solution (to the full chain).
- Resiliency. The messages are processed later when the processes are up. No lost of information.
- Delivery guarantees. Guarantee the message is always processed.
- Ordering guarantees. The data is processed in specific order.
- Buffering. Upload image, buffering layer.
- Asynchronous Communication.
Microservice Architecture
- Single responsability principle. Do one thing and do it well.
- Service autonomy. Each service deploys independently.
- Identical Server Deployments
- Each service has its own server
- Platform as a Service
- Containers (Docker), runs in isolated container
- Benefits:
- Technology diversity
- System resilience. MS can handle total failure of services and degrade functionality accordingly.
- The capability to recover quickly from difficulties
- The ability of a system to cope with change
- System scaling
- X Axis scaling (Horizontal Duplication Scaling by Cloning - Behind a load balancer there are multiple copies). It does not handle or manage the functionality complexity and changes.
- Y Axis scaling (Functional Decomposition - Scale by splitting different services). One action / operation / noun implemented by a service. Atomically.
- Z Axis scaling (Data Partitioning - Scaling by Splitting Data). Each service attending a subset of data. Divide by customer type.
- Easy of deployment
- Commit changes
- Compile code
- Static code analysis
- Execute test
- Packaging
- Deploy to environment
Asynchronous Microservices
- Synchronous
- Asynchronous
- Request / Response
- Event Based
Implementing Microservices and Message Queueing
Technical Requirements
Asynchronous payments for direct customers
Synchronous payments for call center
Queue persistence, for resilience
Scale Out consumers
High Level Design
API and Processors, in the middle a Queue.
Development
- Implement Web API
- Implement Customers
- Topic based Publisher and Suscriber
- RPC
This is the Topic Architecture:
For RPC architecture:
References
https://www.amazon.com/Art-Scalability-Architecture-Organizations-Enterprise/dp/0134032802