I am trying to code a problem in Java where I have to execute a bunch of tasks.
Problem
Execute a job which consists of multiple tasks and those tasks have dependencies among them.
A job will have a list of tasks and each such task will further have a list of successor tasks (Each successor task will have its own successor tasks - you can see the recursive nature here). Each successor task can start its execution if -
It is configured to be executed on partial execution of its predecessor task. In this case, predecessor task will notify that it has completed partially and my successor tasks can start
Successful completion of its predecessor task.
Example
Job having 2 initial tasks A and B. A has 2 successor tasks M and N. B has 1 successor task P. P has 2 successor tasks Y and Z.
M can start on partial completion of its predecessor task A. Z can start on partial completion of its predecessor task P. N, P and Y can start only on completion of their predecessor tasks A, B and P respectively.
I have to design the execution of such a workflow/job. In the design we have to acknowledge the partial completion event sent by a predecessor task so that its successor task can be started. How should I go about it? Is there any design pattern which suits this problem in concurrency?
Take a look at akka - http://akka.io
using akka you create actors (event driven, concurrent entities that process messages asynchronously)
each task can be represented as an actor (you choose when to fire it up)
you can trigger other actors (tasks) on partial complete or full complete (actually you can trigger them whenever you want)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With