0

I am new to Akka. I have 4 actors.

Actor1 sends Message1 to Actor4. Actor2 sends Message2 to Actor4. Actor3 sends Message3 to Actor4.

Actor4 should create Message4 when it receives 1 message of type Message1, 1 Message of type Message2 and 2 messages of type Message3.

Message4 = (Message1, Message2, Message3a, Message3b, Message3c)

What would be the best approach to do this?

dario
  • 5,149
  • 12
  • 28
  • 32
Random
  • 325
  • 1
  • 3
  • 15

2 Answers2

1

If you have a task which depends on other tasks being completed whilst others can be done in parallel, you want to use futures, I have answered a question like this already, this is probably a duplicate question, and just a variation of the more general problem of performing tasks in parallel and distrubuting them across resources as best as possible, but anyway futures give a more clean solution to this problem in my opinion, check out my answer here Executing Dependent tasks in parallel in Java.

Community
  • 1
  • 1
Derrops
  • 7,651
  • 5
  • 30
  • 60
1

I agree with Snickers3192, that you can use futures. You could also look into something like the Cameo Pattern from Jamie Allen. I have created some crude examples in another stackoverflow thread. These are all Scala and not Java.

Futures and Cameo Pattern

Community
  • 1
  • 1
scarpacci
  • 8,957
  • 16
  • 79
  • 144