Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are Akka messages ordered if messages are not reliable?

Tags:

scala

akka

I read that Akka messages are ordered in that between any two actors A and B, if A sends messages in order 1, 2, 3, 4, they must arrive in that order.

Also I read that Akka messages are not reliable.

How can these two things be true? If message arrives 1 and then 4 and then 3, but 2 was never delivered, then what happens?

http://doc.akka.io/docs/akka/snapshot/general/message-delivery-reliability.html


To clarify, if messages 1 2 3 and 4 exist and are sent in that order from actor A.

Lets consider these are points a), b), c) d).

a) At actor B, message 1 arrives.

b) Then at actor B message 4 arrives.

c) Then at actor B message 3 arrives.

d) Message 2 was lost.

At point a) I see no problem, actor B processes the message.

At point b) I see a problem, how can actor B process this message 4 because of message ordering rules, actor B is expecting message 2 to arrive. So I guess at this point actor B cannot process message 4 as message 4 cannot be processes before message 2.

At point c) message 3 has arrived, but we cannot process message 3 without message 2 due to ordering.

At point d) Message 2 has been lost.

So the actor B will only process message 1 and will not process messages 3 and 4, if I apply the rules as I understand them. Is my logic correct? Am I making an incorrect assumption here by assuming that messages could arrive at actor B in any order. However, if two actors are on the internet, shouldn't that be the case? If its fire-and-forget for the message?

like image 360
Phil Avatar asked Apr 16 '14 04:04

Phil


People also ask

Which protocol does not provide guaranteed delivery ordering of messages and duplicate elimination?

The dead letter service follows the same rules with respect to delivery guarantees as all other message sends, hence it cannot be used to implement guaranteed delivery.

What is reliable message delivery?

This means that when a message reaches its physical destination, the broker must place it in a persistent data store. If the broker fails for any reason, it can recover the message later and deliver it to the appropriate consumers.

In which message delivery guarantee approach each message is guaranteed delivery to at least one of the components that retrieve messages from the queue?

at-least-once delivery means that for each message handed to the mechanism potentially multiple attempts are made at delivering it, such that at least one succeeds; again, in more casual terms this means that messages may be duplicated but not lost.

How does Akka handle concurrency?

Akka's approach to handling concurrency is based on the Actor Model. In an actor-based system, everything is an actor, in much the same way that everything is an object in object-oriented design.


1 Answers

As the documentation says, if actor A1 sends messages M1, M2 and M3 to actor A2, those messages will be delivered in that order *relative to messages sent from A1 to A2. If A3 is also sending messages to A2, there is no guarantee regarding how the messages from A1 and A3 will be interleaved. A message from A3 could arrive in-between two messages from A1. Messages from A1 would still be in order relative to other messages from A1.

So in your example, (1, 4, 3) is guaranteed not to happen. (1, 3, 4) is valid since any message can be dropped but if 3 is delivered, it's guaranteed to be delivered before 4.

like image 163
Ryan Avatar answered Nov 15 '22 00:11

Ryan