11

I have created several tasks, each takes an input, an execution function which keeps updating its status, and a function to get output of this task. They will execute in serial or parallel. Some outputs are List so there will be loops as well.

public class Task1 { //each task looks like this
    void addInput(String key, String value){
       ....
    }
    void run(){
       ....
       updateStatus();
       ....
    }
    HashMap getOutput(){
       ....
    }
    Status getStatus(){
       ....
    }
}

I want to make a workflow from these tasks and then I will use the workflow structure information to build a dynamic GUI and monitor outputs of each task. Do I have to write a workflow execution system from scratch or is there any simple alternative available?

Is there any workflow engine to which I can give (in XML may be) my Java classes, input and output and execution functions and let it execute?

SMUsamaShah
  • 7,677
  • 22
  • 88
  • 131
  • 2
    You are looking for a [BPEL Engine](http://en.wikipedia.org/wiki/Business_Process_Execution_Language). – CodeNewbie Sep 24 '14 at 11:21
  • I'm not sure about the use of your project. For commercial, school project or just personal study? – Jiang Sep 28 '14 at 13:53
  • @Jiang I am making it as a prototype/proof of concept for my research project. It is about automating workflows. I am making test case workflow. This is a scientific workflow, search DNAs, convert to protein, find homology, protein modeling and in the end model verification. Each step uses various services. – SMUsamaShah Sep 28 '14 at 19:52
  • And what's more, is the dynamic GUI built on html or swing/awt? – Jiang Sep 29 '14 at 03:53
  • 1
    It is hard to tell if it is appropriate, but https://www.knime.org/knime may be a good solution for you. It is an Elipse based tool which let you visually design workflows of different tasks/nodes. – xpa1492 Oct 01 '14 at 07:56
  • similar thread: http://stackoverflow.com/questions/15353097/generating-bpel-files-programmatically – İsmet Alkan Oct 02 '14 at 12:31
  • @Jiang I am using swing for the UI. workflow execution system which i can monitor and easily accessible workflow structre information is most important. with that i can generate and update UI – SMUsamaShah Oct 03 '14 at 12:35

7 Answers7

4

In Java world, your use case is called as BPM (Business process management).

In .Net world, this is called as Windows Workflow Foundation (WWF).

There are many java based open source BPM tools. The one i like is jBPM.

This is more powerful and can be integrated with rule engines like Drools.

Sample jBPM Screenshot: jBPM Diagram

Also Activiti is another good choice.

Sample Activiti Screenshot: Activiti Diagram

thangamanikasi
  • 846
  • 6
  • 19
2

Check out Activity. This is not strictly designed to solve your use case, but you may use and adapt it's process engine to help you because it's written purely in java. Activity is rather process modeling engine so it's not designed to controll tasks running in parallel at runtime, howerver you will get many things which you can reuse "out of the box".

  • You will get tasks linking basing on xml file
  • You will get your gui for linking tasks for free (basing on eclipse)
  • You will get the GUI in web browser to browse running processes, start new, and see current status of the tasks: http://activiti.org/userguide/index.html#N12E60
  • You will get the reporting engine for free, where you can see reports and charts ("how long time did the tasks take", "how long was the process was running"
  • You will get the REST API for free. Other application will be able to get the current state of your application via simple REST calls

So going in this direction you will get many things for free. From programmer point of View you can for example inherit from Task class from Activity api. Late when the task is completed call

taskService.complete(task.getId(), taskVariables);

You can also go another way arround. So supossing that your class which calculates in background is called CalculationTask, you can connect CalculatinTasks with new instance of Activity Task. By this you will get a bridge to Activity process engine. So you can do something like

class CustomActivityTask extends Task { // inherit from Activity Task class to add your own fields
    private int someStateOne;
    private String someOtherState;

   (...)
   // getters and setters

}

class CalculationTask {
   private CustomActivityTask avtivityTask; // by updating the state of this task you are updating the state of the task in Activity process engine 
   private RuntimeService activityRuntimeServiece;

   public void run() { // this is your execution functin

      while (true) { 
         // calulate
         activityTask.setSomeStateOne(45)
         activityTask.setSomeOtherState("Task is almost completing..."); 

         (...)

         if (allCompleted) {
             activityRuntimeServiece.complete(avtivityTask.getId(), taskVariables);
             break;

        }

  }
}
walkeros
  • 4,736
  • 4
  • 35
  • 47
2

Apache Camel is an open source integration framework that can be used as a lightweight workflow system. Routes can be defined with a Java, XML, Groovy or Scala DSL. Apache Camel includes integrated monitoring capacities. Beside that you may use external monitoring tools such as Hawtio.

Also have a look at Work Flow in Camel vs BPM.

Community
  • 1
  • 1
Peter Keller
  • 7,526
  • 2
  • 26
  • 29
2

Perhaps State Chart XML (SCXML) can help you. Currently it's a Working Draft specification published by W3C

SCXML provides a generic state-machine based execution environment based on Harel State Tables.

The apache foundations provides a java implementation that we(my company) are currently using to perform state-transitions on "jobs". Here is the Apache Commons SCXML implementation

Unihedron
  • 10,902
  • 13
  • 62
  • 72
Alboz
  • 1,833
  • 20
  • 29
2

Take a look at Copper Engine http://copper-engine.org/

Unlike Activiti and such, it does not require to write a ton of XML just to get a simple workflow going

NewlessClubie
  • 983
  • 2
  • 8
  • 18
  • It is not documented. Where can I find its help, api etc? – SMUsamaShah Oct 04 '14 at 09:09
  • The javadoc is available as a jar from maven central and is not on their github for...some reason. Anyway, my team found copper to be pretty lacking. It does not have some fundamental things you would expect from a workflow system - like the ability to define a finite state machine. A workflow is pretty much a FSM and copper does not have any concept of this. You just define a Java class and have to keep polling when you are waiting for completion of external events using their custom version of wait(). I highly encourage people to look elsewhere. – chairbender Jun 27 '17 at 21:42
2

If your analysis is time-consuming and you don't need immediate feedback, then perhaps you don't need a workflow engine at all but a batch processor. Have a look at the Spring Batch project which can be used together with Camel Apache (see my other answer for more information about this option).

Peter Keller
  • 7,526
  • 2
  • 26
  • 29
1

I would definitely consider the Apache Storm project. Storm is designed to be an easily-extensible, parallel computation engine. Among its many features, its ease of management, fault tolerance and general simplicity to set up (in comparison to other similar technologies like Hadoop, I believe) are probably going to be attractive to you for a prototype system.

Workflows would be analogous to Storm topologies; the different tasks would be streams; and the different methods in tasks would correspond to spouts and bolts. Also, Storm supports several programming languages in its API, like Hadoop.

Storm was initially designed by Twitter and then open-sourced, similarly to other projects like Cassandra (Facebook) and Hadoop itself (Yahoo!). What that means for you as a user is that it was built for actual use, instead of as a purely theoretical concept. It's also pretty battle tested.

I hope this was useful to you, and wish you the best of luck with your project!

Juan Carlos Coto
  • 11,900
  • 22
  • 62
  • 102