Given an Actor system where some persistent actors can have external identifiers that must be unique, how can we enforce this constraint ?
I would prefer a hierarchy of actors where the parent maintains a set of external identifiers to ensure that it is not yet used when creating a child. The issue with that model is that the hierarchy add dependencies between parent and child while our system is almost flat to have independent actors in their own modules. Another issue may be the throughput where the parent will buffer all creation commands to validate them one by one before creating/delegating to a child actor.
The more I think about it, the more I feel that this will be the simpler solution in our system. However the dependencies may be an issue, but there may be some patterns to reduce the coupling between parent and “child” actors.
Another solution in messaging systems seem to let the actor managing his own unique constraint by sending a message via
AtLeastOneDelivery to another actor that represents the unique value. (Like that one https://github.com/mattroberts297/akka-saga-pattern-talk-code)