Check if an actor (Abstract / sharded / event source) with an ID is already created

Hi ,

Is there a way to check if the actor is already created, using a unique ID ?

We have a requirement, to follow certain different behaviors with new and existing actors.

Thanks.

One way would be to have the actor store a Created event in response to being created and have different behaviors to other commands/queries for non-created (reply and stop itself for example) or created. There is a somewhat related example of optional state in the docs here: https://doc.akka.io/docs/akka/current/typed/persistence-style.html#optional-initial-state