Active Actors - Implementing Workflows, Actions, or Dialogs

Let's say I want to implement ProgrammableRemote in akka -

ProgrammableRemote - WatchMovie 1. Tv ! PowerOn 1.1 Tv ! ChangeInput 3 2. DVD ! PowerOn 3. AVReceiver ! PowerOn 3.1 AVReceiver ! SetInput 'DVD' 

I could use futures for sequences 1 and 1.1 (and 3. and 3.1). However, this will lead to 1.1 being executed in a separate thread from the actor receiving thread. If I use `pipeTo self ', I will need to process the register for the message" PowerOn completed "from the TV in the" receive "method.

Ideally, I would like to be able to expand the actor to receive responses from other participants dynamically based on outstanding requests. Is there any solution in akka for this use case?

+4
source share
1 answer

I will just send messages, their order will be saved for each sender, so if you get ChangeInput before it is turned on, you still have to deal with it. Use the "become" or DSL Akka FSM to encode different states and what commands are possible in each state.

+1
source

Source: https://habr.com/ru/post/1441034/


All Articles