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,021
  • 12
  • 27
  • 32
Random
  • 175
  • 2
  • 14

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
  • 6,833
  • 4
  • 27
  • 50
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,525
  • 16
  • 75
  • 135