Michael
Michael

Reputation: 1467

Is there a pattern to create Akka-Actors if they're not present?

I'm currently playing with Akka. My goal is to create a Telegram-Bot and handle the state of each chat with a separate Akka-Actor.

I have a component that receives messages from Telegram and that will forward the messages to the according actors. Therefore I have to create an actor for every new chat. I don't want to do that in my Telegram-Query-Component since it shouldn't bother if an actor exists or not.
The path to the actors could be something like clients/client-id. If I send a message from the Telegram-Component to the path it ends up in the dead letter queue currently.

Is there a way that messages end up in the clients-parent-actor if the child actor is not present? Is there another way to automatically create actors if they are not present?
And: What's a common solution for my "problem" in the Akka-environment? Have something like a registry, or route every message via the clients-parent-actor per default?
Thanks for your help, Michael

Upvotes: 0

Views: 115

Answers (1)

Rob Crawford
Rob Crawford

Reputation: 556

Akka clustering does this -- actors are created when a message is sent to them.

I've created actors to route messages, creating the recipient if needed. I don't think there's anything outside the clustering that does this automatically, but it's not difficult to implement.

Upvotes: 0

Related Questions