Does redis pubsub guarantee messages being delivered in sequence? - redis

If publisherA publish one message before publishB. Is it guaranteed that a subscriber will receive messages in the same sequence i.e. message of publisherA will be received first.

The order of messages delivered by Redis is determined by the order of the messages' arrival/publishing. If publisherA's message is received and handled before that of publisherB's, then the messages will arrive in order to the client (ensured by the TCP stack).

Related

How to understand on the consumer side that some messages were dropped within RabbitMQ

There is a single consumer that receives all messages from a particular queue. The source of the messages is a single publisher. In my case it is a one-way communication and it is important to deliver all messages in order without losses. How can the consumer know that some messages have been dropped by RabbitMQ, for example, because the queue size limit has been reached?
I know that a message sequence number (defined by RabbitMQ) is used to confirm delivery to the consumer, so the question is: Is the sequence number a signal that messages have been dropped? For example, if the sequence number is not linear (difference between the received message and the previous message is greater than 1).

Get messages at consumer at exact order that was published - RabbitMQ - MassTransit

I am passing payment related data through queue. So I need to receive data at my consumer in same order that I have send.
Example - Publisher publish these message - msg1, msg2, msg3...msg8. At Consumer am not getting it in correct order that was published... it comes like msg1,msg4,msg2,msg7.msg8.. All the messages are of same type.. Is there any way to handle this in rabbitmq masstransit ?
Purely pub-sub message brokers cannot guarantee ordering by design. Publisher acknowledgements and consumer acknowledgements aren't ordered, so messages can be published out of order (although you do it sequentially) and consumed out of order. When a message ends in the poison queue, the next message gets processed, so the order is broken by definition.
In addition, RMQ itself guarantees "at least one" delivery, which means that you can get the same message twice from the broker, out of order. Also, if RMQ cluster gets partitioned by network failure, the state of queues won't properly replicate, and the detached node will resend all the messages it has from its queues when the partitioned state is resolved.
Ordered delivery can only be supported with brokers that use append-only logs. You can do it with Kafka, for example. That's the reason that Kafka transport in MassTransit is implemented as a Rider, not as a normal message transport, due to the conceptual mismatch.

How do I make my Last Image Recovery Policy topic survive broker restarts?

I have configured a topic in ActiveMQ with lastImageSubscriptionRecoveryPolicy. It works as expected in that the broker persists the last message sent to the topic and when a new consumer subscribes to that topic it receives that last message:
producer publishes N messages
consumer A subscribes to the topic; 1 message is received
consumer B subscribes to the topic; same 1 message is received
However, the message is lost when I restart the broker. This is the sequence of events:
producer publishes N messages
broker is restarted
consumer subscribes to the topic; nothing is received
Is it possible to enable persistence of that last message (Last Image) so that it is persisted even across broker restarts?
No this is not possible. If you need message durability then you either need to use a Queue, or use a Durable Topic subscription in order to keep messages around after restart. The broker has some convenience features for Topics such as recovery policies but they are no real substitute for the stronger guarantees that exists for Queue based messaging, so if you need that then you must use those mechanisms.

When message will be erased from queue?

Let's suppose we have one producer, one queue and some consumers which are subscribed on queue.
Producer -> Queue -> Consumers
Queues contains messages about life events. These messages should receive all consumers.
When queue will be erased?
When all consumers get message?
Or when one of consumers confirm message with flag ack (true)?
And how to manage priority, who from consumers must to get message first/last (don't confuse with message priority).
As instance I have 10 consumers and I want that the fifth consumer get message first, remaining consumers later after specified time.
Be careful: when there are many consumers on one queue, only one of them will receive a given message, provided that it is consumed and acked properly. You need to bind as many queues as consumers to an exchange to have all consumers receive the message.
For your priority question, there is no built-in mecanism to have consumers receive the same message with a notion of priority: consumer priority exists (see https://www.rabbitmq.com/consumer-priority.html), but it is made to have consumer receive a given message before the others on a given queue, so the other consumers won't receive this message. It you need to orchestrate the delivery of your messages, you have to think of a more complex system (maybe a saga or a resequencer?).
Note that you can delay messages using this pattern. Again, this requires having multiple queues.
Finally, there are many scenarios when a queue is deleted. Take a look at the documentation, these are well explained.

1 publisher, 2 consumers: If I set a queue up that requires acks, first consumer doesn't ack, will second consumer receive message?

So the scenario is 1 publisher and 2 consumers. The queue requires acks from consumers in order for the message to be removed from the queue.
1st consumer receives message from queue but doesn't ack so the message stays on the queue.
When the 2nd consumer reads from the queue, will the 2nd consumer receive the message? or does the publisher have to wait for a Nack from 1st consumer, in order to be able to pass on that message to 2nd consumer?
Until an acknowledgement is received (ack or nack) the message will remain on the queue but not be delivered to another competing consumer.
Only when a nack with requeue=true is sent will another consumer get it. And there is no guarantee that it will be consumer 2. If consumer 1 is still going then perhaps it will get delivered back to consumer 1. It depends if there have been other messages that have been processed in that time period.