I am making a publish/subscribe typical application where a publisher sends messages to a consumer.
The publisher and the consumer are on different machines and the connection between them can break occasionally.
The goal here is to make sure that no matter what happens to the connection, or to the machines themselves, a message sent by a publisher is always received by the consumer.
Ordering of messages is not a must.
According to my research, RabbitMQ is the right choice for this scenario:
However, although RabbitMQ has a tutorial about publish and subscriber this tutorial does not present us to persistent queues nor does it mention confirms which I believe are the key to making sure messages are delivered.
On the other hand, Redis is also capable of doing this:
but I couldn't find any official tutorials or examples and my current understatement leads to me to believe that persistent queues and message confirms must be done by us, as Redis is mainly an in memory-datastore instead of a message broker like RabbitMQ.
RabbitMQ handles large messages way better than Redis. It guarantees delivery of messages and thus preferable when you can't afford messages loss. It doesn't guarantee the delivery of each message.
Redis Pub/Sub is an extremely lightweight messaging protocol designed for broadcasting live notifications within a system. It's ideal for propagating short-lived messages when low latency and huge throughput are critical. Redis Lists and Redis Sorted Sets are the basis for implementing message queues.
Redis or REmote DIctionary Server is an advanced NoSQL key-value data store used as a cache, database, and message broker. It provides tools like Redis message queue for message broking. It is known for its rich data types, fast read and writes operations, and advanced memory structure.
RabbitMQ is one of the most popular message brokers, with tens of thousands of users. It is a lightweight messaging system that can be deployed on-premises or in the cloud. Besides, it may be deployed in distributed and federated configurations to meet high-scale, high-availability requirements.
I originally wanted publish and subscribe with message and queue persistence.
This in theory, does not exactly fit publish and subscribe:
Indeed, looking at my needs I would need more of a Work Queue pattern, or even an RPC pattern.
People say both should be easy, but that really is subjective.
RabbitMQ has a better official documentation overall with clear examples in most languages, while Redis information is mainly in third party blogs and in sparse github repos - which makes it considerably harder to find.
As for the examples, RabbitMQ has two examples that clearly answer my questions:
By mixing the two I was able to have a publisher send to several consumers reliable messages - even if one of them fails. Messages are not lost, nor forgotten.
Downfall of rabbitMQ:
As for redis, it has a good example of durable queues in this blog:
Which follows the official recommendation. You can check the github repo for more info.
Downfall of redis:
This is, in my opinion, a worst rabbitmq.
I ending up going with rabbitmq for the following reasons:
With this in mind, for this specific case, I am confident in saying that redis is a worst rabbitmq in this scenario.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With