Wednesday, October 5, 2016

Adding dynamic behaviour to the Flowable Engine

We have added a new feature to the Flowable Engine that I would like to share with you even before it's available as part of an official release. The new feature is the ability to change a defined number of properties of a process definition without needing to redeploy the process definition.

Before I'll go into details about this feature, some examples of needing to redeploy a process definition would be good to set the context. One example is a service task with a defined class name in the process definition. This service task is part of a big process definition, and process instances can be active for over a year. After deploying the first version of the process definition to the production environment the requirements of the process execution have changed and a new Java class should be executed for the service task instead. This means that new deployment of the process definition is needed and existing process instances need to be migrated to this new process definition.

Another example is a user task with a candidate group management. Over time, the requirements have changed and the sales group needs to be set as the candidate group for this user task. Again, this would mean a new deployment of the process definition and migration of existing process instances.

With the addition of the DynamicBpmnService interface these use cases can be solved differently, without the need to redeploy the process definition. For example, the DynamicBpmnService interface has a method to change the class name of a specific service task named changeServiceTaskClassName. Let's look at a code example to change the class name of the exampleTask service task.

<serviceTask id="exampleTask" 
  flowable:class="org.flowable.PreviousTask" />

ObjectNode infoNode = dynamicBpmnService.changeServiceTaskClassName(
      "exampleTask", "org.flowable.NewTask");
dynamicBpmnService.saveProcessDefinitionInfo("procDefId", infoNode);

After the invocation of the saveProcessDefinitionInfo method the Flowable Engine will now execute the NewTask class instead of the PreviousTask defined in the BPMN XML. As you can see we are using Jackson JSON for storing the overriding process definition information in the Flowable database. Every process definition can have zero or one entry in the new ACT_PROCDEF_INFO table. All changes for a process definition are defined in the same JSON object and stored as a BLOB in the Flowable database. The cache that's used to retrieve the process definition info data is versioned and designed to work in a clustered Flowable environment.

Let's look at one more example, changing the candidateGroup of a user task:

<userTask id="exampleTask" flowable:candidateGroup="management" />

ObjectNode infoNode = dynamicBpmnService.changeUserTaskCandidateGroup(
      "exampleTask", "sales", true);
dynamicBpmnService.saveProcessDefinitionInfo("procDefId", infoNode);

Again, after saving the JSON object, the Flowable Engine will use the sales candidate group for the exampleTask user task instead of the management group.

If you want to override multiple properties of a specific process definition in different steps you need to get the currently stored JSON object first. This is easy to do like this:

ObjectNode infoNode = dynamicBpmnService.getProcessDefinitionInfo("procDefId");

These are the properties we currently support to change with this approach:
  1. Service task - class name
  2. Service task - expression
  3. Service task - delegate expression
  4. User task - name
  5. User task - description
  6. User task - due date
  7. User task - priority
  8. User task - category
  9. User task - form key
  10. User task - assignee
  11. User task - owner
  12. User task - candidate users
  13. User task - candidate groups
And there's an additional feature we have implemented with the same approach, which is localisation. It's now possible to store the user task name and description in multiple languages in the process definition info table and when you query for tasks you can set a locale to use. The returned tasks will then contain the localised name and description as defined in the process definition info table. Let's look at an example:

<userTask id="exampleTask" name="Name" />

ObjectNode infoNode = dynamicBpmnService.changeLocalizationName(
      "es", "exampleTask", "Nombre");
dynamicBpmnService.saveProcessDefinitionInfo("procDefId", infoNode);

Task task = taskService.createTaskQuery().locale("es").singleResult();

The returned task instance will now have Nombre as the name of the task.

We are really excited about this new feature that's available in both the Flowable 5 and 6 code that's in Github, and we are eager to get feedback about this new feature. Let us know what you think about it and maybe come up with suggestions of which properties we could add to this approach in addition to the current supported list. We'll do a 5.18.1 release in a couple weeks time, together with a new beta release for Flowable 6, that will include this feature. And you can already create your own build using the code on Github of course.

33 comments:

  1. What about changing the script inside a script task without redeploying?

    ReplyDelete
  2. Good point, will include that as well.

    ReplyDelete
  3. What about creating ad-hoc processes/tasks, ACM so to say?

    ReplyDelete
  4. What about creating ad-hoc processes/tasks, ACM so to say?

    ReplyDelete
  5. This is a really nice feature.
    This could also be interesting for the properties of a mail task, the properties for a timer event and even the signal reference for the signal event.

    ReplyDelete
  6. When is the next official release date? Will it include Spring Boot 1.3+ to take advantage of the new dev tool capabilities?

    ReplyDelete
  7. Thanks for the feedback, I've added sequence flow condition and script task support for the dynamic BPMN functionality. @Tom, your suggestions are welcome as well, and I'll have a look at adding support for it.
    We didn't upgrade to Spring boot 1.3 yet, any help with this would be welcome.

    ReplyDelete
  8. Srinivasan VaradarajanNovember 19, 2015 at 11:03 PM

    This is a great feature for building a process framework where multiple tenants will use a standard process model (a Reference Data pipeline model with ETL like properties, for instance), but each tenant can supply their own variations of the task class implementations.
    Thank you!

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. hello rally good feature. i am new in activiti-explore and i m read many post but i don't have idea how to use it in android app or web app . i am use activiti 5.18 throught rest but it is more hardcoded . can i used these java classes in my android app or have any sdk? please help

    ReplyDelete
  11. Right now, this is a Java API only feature, but we'll add support for the new DynamicBpmnService interface to our REST API as well.

    ReplyDelete
  12. hello i am using the activiti 6ui.
    but here is a problem when i create a workflow through kikstart app
    In user task , from properties attribute , when select type is enum type then not come its value type for choose yes or no ?

    ReplyDelete
  13. palanirajkumar

    hello sir ,
    sir give me the simple program for activiti bpmn restfulservices

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. Thank you for allowing me to read it, welcome to the next in a recent article. And thanks for sharing the nice article, keep posting or updating news article.
    java training in chennai | java training in USA

    selenium training in chennai

    ReplyDelete
  17. A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. I am learning a lot from you.
    python training in annanagar
    python training in chennai
    python training in chennai
    python training in Bangalore

    ReplyDelete
  18. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    Devops training in velachery
    Devops training in annanagar
    Devops training in tambaram
    DevOps online Training

    ReplyDelete
  19. I simply want to give you a huge thumbs up for the great info you have got here on this post.
    Blueprism online training

    Blue Prism Training in Pune

    ReplyDelete
  20. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information..

    rpa training in electronic-city | rpa training in btm | rpa training in marathahalli | rpa training in pune

    ReplyDelete
  21. The post is written in very a good manner and it entails many useful information for me. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept.
    angularjs Training in bangalore

    angularjs Training in btm

    angularjs Training in electronic-city

    angularjs online Training

    angularjs Training in marathahalli

    ReplyDelete
  22. Really great post, I simply unearthed your site and needed to say that I have truly appreciated perusing your blog entries.
    Python training in marathahalli | Python training institute in pune

    ReplyDelete
  23. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.

    java training in chennai | java training in electronic city

    java training in marathahalli | java training in btm layout

    ReplyDelete
  24. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    advanced excel training in bangalore

    ReplyDelete
  25. Does your blog have a contact page? I’m having problems locating it but, I’d like to shoot you an email. I’ve got some recommendations for your blog you might be interested in hearing.
    AWS Training in Chennai |Best Amazon Web Services Training in Chennai
    AWS Training in Rajaji Nagar | Amazon Web Services Training in Rajaji Nagar

    Best AWS Training Institute in BTM Layout Bangalore ,AWS Coursesin BTM

    ReplyDelete
  26. Good job in presenting the correct content with the clear explanation. The content looks real with valid information. Good Work

    DevOps is currently a popular model currently organizations all over the world moving towards to it. Your post gave a clear idea about knowing the DevOps model and its importance.

    Good to learn about DevOps at this time.


    devops training in chennai | devops training in chennai with placement | devops training in chennai omr | devops training in velachery | devops training in chennai tambaram | devops institutes in chennai | devops certification in chennai | trending technologies list 2018

    ReplyDelete
  27. Greetings. I know this is somewhat off-topic, but I was wondering if you knew where I could get a captcha plugin for my comment form? I’m using the same blog platform like yours, and I’m having difficulty finding one? Thanks a lot.

    AWS Interview Questions And Answers
    AWS Tutorial |Learn Amazon Web Services Tutorials |AWS Tutorial For Beginners
    AWS Online Training | Online AWS Certification Course - Gangboard
    AWS Training in Toronto| Amazon Web Services Training in Toronto, Canada

    ReplyDelete
  28. If you happen to be interested, feel free to shoot me an e-mail. I look forward to hearing from you! Great blog by the way!
    nebosh course in chennai

    ReplyDelete