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?
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.
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.
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.
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.
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.
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