문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top