I am trying to write a event based task execution in a workflow using Java and Spring. Could someone help with approach that could be taken for this? What I would like to do is following -
1.) A workflow would have set of activity configured to execute.
2.) Each activity would need to fire based on a event occurring. For example, if there are two activities in a workflow, upon completion of activity 1 the activity 1 would raise event. Based on that event the activity 2 would be triggered and passed the context raised from the activity 1. Once activity 2 completes it would raise a completion event along with context object. Once this event is raised, a activity that is waiting for trigger of this event kicks off and executes its part.
3.) The workflow reaches to end state once all the activities are marked complete and at that point the context object would be the final state object.
4.) Every time a activity is invoked based on a event the activity is fired in a new thread, I am thinking prototype bean in Spring.
Keeping above in mind, it seems like I need to implement Mediator pattern in some way. I looked at both the Mediator pattern and Chain Of Responsibility pattern but it looks like chain of responsibility pattern is sequential in nature and almost looks like I need command pattern with each command object as prototype and mediator pattern helping mediate the event based flow.
Is it doable that way? Could someone please opine with how to go about this? I am looking for Java 7 and Spring based implementation.
Aucun commentaire:
Enregistrer un commentaire