Reputation: 4138
I need atomic broadcast and I want to use akka cluster.
I'm not sure is there atomic broadcast in akka, so I just want to ask, to be sure.
I know, there are such things like DistributedPubSubMediator.SendToAll
aswell as Cluster Aware Routers
. Does any support total order broadcast ?
By atomic (total order) broadcast I mean, actor A sends broadcast bA aswell as actor B sends broadcast bB (in parallel & from another node). Eventually, (every actor receives message bA before bB) or (every actor receives message bB before bA).
Upvotes: 1
Views: 231
Reputation: 22374
By default there is no such guarantee as messages are sending asynchronously. But you can just use some mediator X
(any actor including DistributedPubSubMediator
) which will induce such guarantee: send (bA, recipients)
from A
to X
, send (bB, recipients)
from B
to X
, and X
should just broadcast every message to its recipients (it will be "atomic" and sequential, as done inside one actor).
If you need to do this in cluster - you could try "Cluster Singleton" to avoid single point of failure by sacrificing high availability and maybe partition-tolerance (you will have to remove nodes manually from the cluster to allow the "P")
Upvotes: 1
Reputation: 7247
The only ordering guarantee offered by Akka is that messages sent from actor A
to actor B
will be received in order for that pair of actors. Messages from other actors to actor B
could be received before, after or interleaved with the messages from A
to B
.
So no, Akka does not provide the ordering guarantee you're asking for.
Upvotes: 3