From the Dexecutor Website
Executing dependent/Independent tasks in a reliable way, is made so easy that even grandma can do it.
That is indeed true with Dexecutor, specially considering the complexity involved writing error free programs involving dependent/Independent tasks. Without Dexecutor, you would end up writing tons of plumbing code rather than concentrating on the business.
With Dexecutor, you model your requirements in terms of Graph in an object oriented way, and rest would be taken care by the framework in a reliable way. Dynamically built graph, defines the executing order, what are all tasks that should run in parallel/sequential. For example if the graph built is the following
Then it means, Task#1,Task#12 and Task#11 would run in parallel, once one of them finishes execution, its child nodes would begin execution. For example lets say if Task#1 finishes, then Task#2 and Task#3 would begin, similarly with Task#12 and Task#11, until all the tasks are executed or if a task end up in an error (If the execution behaviour is terminating)
That’s great indeed…. But how it is done ?
DefaultDependentTasksExecutor<Integer, Integer> executor = newTaskExecutor();
//Build the graph
//executor.addDependency(10, 2); // cycle
Above code shows, Dexecutor expose two kind of APIs,
- An API to construct the Graph (addDependency, addIndependent)
- An API to Start execution (execute)
That’s simple indeed, You may be wondering, How the tasks are mapped?
TaskProvider to the rescue. TaskProviders, maps a graph node to a task, and is basically provided during Dexecutor instance creation. Refer to JavaDoc of Dexecutor Implementation, and an example of how to do it.
Well, the example is very simple, Can we get any real time example of how Dexecutor can be used?
Yes indeed, Dexecutor does have a sample application which provides a real time scenario, refer it for more details.
Finally I would like to quote the features of Dexecutor, Here is a snapshot from the website.