Can somebody explain me in what use-cases I should consider using AMQP like e.g. RabbitMQ? What are the pros and cons?
Imagine that you have a web service that can accept many requests per second. You also have a accounting system that does a lot of things, one of which is processing the requests coming from the web service.
If you put a queue between the web service and the accounting system, you will be able to:
- have less coupling between the two applications, because now both applications have to know the configuration parameters of the queue management system and the name of the queue. Here the catch is that usually you are more likely to move to another server some application than move the queue management system
- if you have a lot of requests coming in a short amount of time, the accounting system will be able to process them all anyway
- persist some requests if their number becomes really huge
Of course, you could have more complex situations where the number of your applications is much bigger than two and you need to manage the communication between them.
In addition to providing a buffer between a web service and another backend service, message queues can be used for more advanced scenarios. Rabbit MQ (and other mature Message Queue products also referred to as MOM -- Message Oriented Middleware) can be configured to route and distribute messages according to different rules.
For example the Pub-Sub routing technique allows a single source to send a message and have many listeners receive it. This is commonly used by stock trading software to keep the users on the floor updated.
Also because of the fact that most MOMs have sdks for multiple languages and platforms, they can be used to integrate applications that are written on different platforms.
These are just a few of the scenarios enabled by MOMs.