Search code examples
scalaakkaactor

Transitive ordering of messages in Akka Actors


Is there any simple way to enforce transitive ordering of messages in Akka?

For example I have

  • A sending M1 to C
  • A sending M2 to B
  • B forwards M2 to C

How do I ensure C gets (or interprets) M1 before M2 in a simple way?


Solution

  • There are a few of ways you could do this:

    1. Have C send a reply to A when it receives M1 and delay sending M2 to B before the reply is received.

    2. Send M2 to C and have C forward it to B

    3. Put a flag in M2 to say that it depends on M1 and have C stash M2 if it arrives before M1