Hello,
I am currently evaluating Akka with Akka Persistence for new project in our company. I am new to DDD and builiding Microservices the reactive way (with actors and without), but I like what I have seen so far.
As of now, I have worked through the IoT example as well as the platform guide with the shopping cart and am now trying to build a minimal proof-of-concept with only a few commands / events and a single EventSourcedBehaviour.
At the moment, I am a bit lost how to implement a specfic requirement with Akka Persistence; one that is actually beautifully showcased in the IoT example. For illustration purposes, I have also created a small tactical design diagram (see attachment).
In summary, I need to:
- Be able to receive a lot (millions) of events of type âPart receivedâ from an external system within a very short time (eg during inital setup for a new customer). They are âParts (Entity)â of a âDevice (RootEntity)â. Parts can reference each other and basically form a unidirectonal graph. Parts are received in random order. There can also be a lot of devices (lets say also a few 100k up to a million).
- When I receive a part I need to be able to ask if there is already a âDeviceâ that contains a âPartâ that is referenced from the incoming âPartâ. If yes the incoming âPartâ should be attached to the device. If no, the incoming âPartâ should create a new âDeviceâ and attach itself to it.
- I need strong consistency for all of this.
So my question would be how to actually implement this efficient âask-if-there-is-a-Device-Actor-that-should-handle-thisâ with Akka Persistence and EventSourcedBehaviour
. I am pretty sure I am missing something very obvious here.
What I have checked so far:
- The IoT example deals with this in general simply by having a hierarchy of actors where the parents just query their children. I could imagine to somehow also group Parts and do it the same way, but it seems that using child actors is not recommended when using event sourcing (Is it common to stop child actors in event sourcing? - #2 by octonato)
- The Shopping Cart example showcases the usage of the interaction pattern âRequest-Response with ask from outside an Actorâ, but this would require me to already have an ActorRef at hand.
- To discover Actors, there seems to be the âReceptionsâ, but documentation suggests that I can only go looking with a known ServiceKey.
Any pointers into the right direction would be greatly appreciated.
Thx