- [Instructor] RabbitMQ is a technology you can use in message-based systems. Let's jump right in and look at what a message-based system is, and why they're used. A simple way of connecting services to each other is to have one call the other directly. This is called an RPC-style communication. RPC is short for remote procedure call. Each service will have a specific address, a way of finding that specific service. This is often a URL or an IP address. So the sender needs to know the address of the receiver. This can grow to quite a large list when the amount of services increases. When a receiver's address changes all senders that depend on this service need to be updated. Message-based systems work differently. In a message-based system we put a message broker in between the two services. A sender sends a message to the message broker, and the broker has then been configured to send this message to the receiver. This system provides several advantages over RPC-based systems. First of all, the sender no longer needs to know where the receiver is located. There can even be multiple receivers without the sender needing to know. The message broker can also duplicate the messages and you can easily add new receivers without changing the sender. A message-based system also gives you the possibility of queuing messages. If processing is slow the messages will just wait to be picked up. If the receiving service is down messages won't be lost. This all comes down to the fact that you can decouple the different parts of your system. What this means it that the separate components of your system only need to know a minimum of details of the other components. This allows for more flexibility as your system evolves. However, there are some consequences of using a message-based system. Communication is now asynchronous. This means that the sending service will not receive an answer immediately, if at all. Also, the message broker is now a crucial component of your application. Without it services will no longer be able to communicate with each other. Luckily, this can be mitigated by having multiple instances of RabbitMQ running, and this is called clustering. And the final consequence of using message-based systems is that it can lead to increased network traffic. These aren't deal breakers, but be aware of them as you build your message-based system.
No comments:
Post a Comment