I am trying to build a customizable workflow or kind of state transition which user should be able to update through UI.
Basically it should have all the states and user should be able to choose the transition from one state to another and also hook any predefined action to it. The predefined action could be anything like user task, email task or script task.
It should be flexible enough to add more states / actions to it.
I tried evaluating Activiti but it doesn't look like a good fit here. In fact Workflow engine doesn't look like a right candidate.
Can someone suggest any existing framework or library which I can use.
You can try using JBPM. I have used it in my earlier project.
http://www.jbpm.org/[Jbpm Home][1].
Drawback
JBPM 5 doesnt support clustering. (Not sure if It is fixed in JBPM 6)
I have chosen Squirrel foundation as my backend state transition machine. Decorated with my custom palates for denoting different kind of state (user intervention, service , email etc). And using Viz.js for visualizing and creating the workflow in JS.
Related
I am trying to provide the users a way to generate their own workflow as part of the system.
These workflows will be custom paths an order will take depending on customer requirements.
For example: If a customer requires us to sign a set of terms and conditions, the order should not be able to be approved unless a T&C document has been uploaded.
I have been looking at using bpmn-js for the frontend and execute the output BPMN2.0 file every time something changes that is related to the workflow (i.e. hooks on when documents are uploaded in this case) but it doesn't look like the users will be able to select actual system functionality with that library out-of-the-box. Should I try to extend that library or is there something else I could use instead?
I have been looking into using Camunda as well, but it would be nice to not expect the users to use a second application.
Design your application in a way that the business process will be driven by the process engine. When a process is initiated it start a process instance. From there the process engine (embedded in your existing Java application or standalone back-end service) determines if business rules (DMN) need to be evaluated (all required data and approvals present?), services need to be called (invocation of your java code directly), automated (external task pattern) or user task need to be completed by technical workers (any language) or human process participants (based on assignment determined by engine).
If humans are involved, the UI/client queries the process engine for pending user tasks and updated those tasks when humans have performed the tasks.
The process engine will determine the next steps based on the interpretation (no code is generated) of the BPMN2-standard-based process model. Versioning for these is provided ootb. Newly started processes are automatically started on the latest version while running process instances continue their life-cycle on the version they were started on (unless they are migrated).
It is usually not an issue if users need to access a dedicated modelling environment at design time. They just should not have to work with two applications at runtime. Anyway, it is also easily possible to integrate the modelling part into the same application via the BPMN-js library you mentioned.
The "selection of system functionality" is done by selecting the implementation type and setting the corresponding attributes. The BPMN-JS library is generic in this regard. have a look at how this is done in the Camunda Modeler (https://camunda.com/products/camunda-bpm/modeler/):
Java: https://docs.camunda.org/get-started/java-process-app/service-task/
Spring: https://docs.camunda.org/get-started/spring/service-task/
External: https://docs.camunda.org/manual/latest/user-guide/process-engine/external-tasks/
I am creating an application that concern the activities to be carried out in a company.
These tasks can go through n states (e.g. new, in progress, completed, canceled).
The status step is determined by both the previous state and the user who is currently logged on.
What is the best way to handle all this in a spring boot application? A BPM engine?
Thanks
If its as simple as you suggested, list of rules, Drools should be fine.
If its more elaborate, please have a look at activiti
Both easily integrates with SpringBoot.
The aim is to build a state machine in java which has
An initial state and which can make transition based on a given target state id.
It can output a set of possible transitions which can be reached from the target state id.
It can be achieved by simple coding but i want the workflow to be configurable.
This requires some work. I wanted to know if there is an existing library in java which does this. I came across activiti but i don't know how to use it for my scenario. If it can be used for the scenario, please mention exact steps needed to configure it for the same. Or if there is any other alternative for this.
Given your requirements, I'm not sure Activiti is a good fit, since it is a full blown workflow engine, with users/groups, a modeling application, and a set of existing processes.
I'd probably look at specialized state machine like: https://github.com/oxo42/stateless4j
Two more open-source state machine library you can use
1) SCXML(State Chart XML): http://commons.apache.org/proper/commons-scxml/guide.html
2) Spring state machine:http://docs.spring.io/spring-statemachine/docs/1.2.0.BUILD-SNAPSHOT/reference/htmlsingle
We are embedding Activiti in an application and have some specific requirements towards searching for tasks that go beyond the out of the box Task query capabilities of Activiti. I'm currently considering integrating ElasticSearch and maintaining a specialized index of tasks. For that to work I need to intercept task creation in Activiti.
I haven't found a "native" and transparent (in that I should not have to explicitly model this into my workflows) Activiti mechanism for this (like an interceptor mechanism). At the moment my best bet looks to be to write an myBatis intercepter plugin.
Before I commit to this I wanted to make sure I'm not missing a cleaner/easier method.
I have written a post about this. Check out http://developer4life.blogspot.com/2012/02/extending-task-service-in-activiti.html
If you are using CDI (Weld), have a look at the Activiti User Guide, section "Receiving Process Events": http://activiti.org/userguide/index.html#N12DA5
We have an issue where a Database table has to be updated on the status for a particular entity. Presently, its all Java code with a lot of if conditions and an update to the status. I was thinking along lines of using a Workflow engine since there can be multiple flows in future. Is it an overkill to use a Workflow Engine here... where do you draw the line ?
It depends on the complexity of your use case.
In a simple use case, we have a database column updated by multiple consumers for each stage in an Order lifecycle. This is done by a web service calling into the database.
The simple lifecycle goes from ACKNOWLEDGED > ACCEPTED/REJECTED > FULFILLED > CLOSED. All of these are in the same table on the same column. This is executed in java classes with no workflow.
A workflow engine is suited in a more complex use case which involves actions on multiple data providers eg: database or Content Mgmt or Document Mgmt or search engine, multiple parallel processes, forking based on the success/failure of a previous step, sending an email at a certain step, offline error alerting.
You can look at Apache ODE to implement this.
We have an issue where a Database table has to be updated on the status for a particular entity. Presently, its all Java code with a lot of if conditions and an update to the status.
Sounds like something punctual, no need for orchestrating actions among workflow participants.
Maybe a rule engine is better suited for this. Drools could be a good candidate. When X then Y.
If you're using Spring, this is a good article on how to implement your requirement
http://www.javaworld.com/javaworld/jw-04-2005/jw-0411-spring.html
I think you should consider a workflow engine. Workflow should be separated from application logic.
Reasons:
Maintainable: Easier to modify, add new flows and even easier to replace by another workflow engine.
Business Process management: Workflows are mostly software representations of BPM. So it is usually designed by process designers (Non-tech people). So it is not a good idea to code inside the application. Instead BPM products such as ALBPM or JPBM should be used which support graphical workflow designs.
Monitoring business flows: They are often monitored by the Top level managers and used to make strategic decisions.
Easier for Data mining/Reports/Statistics.
ALBPM(Now Oracle BPM): is a commercial tool from Oracle suitable for large scope projects.
My recommendation is JBPM. Open source tool from JBOSS. Unlike ALBPM which requires separate DB and application server, it can be packaged with your application and runs as another module in your application. I think suitable for your project.