Tuesday, November 8, 2016

Flowable 6 adds ad-hoc sub process support

With the first official release of Flowable 6 approaching we have added support for ad-hoc sub processes. It's a feature that shows the strength of the Engine refactoring we have been doing, because it's a fairly simple implementation on an Engine level. Let's have a look at what's possible with ad-hoc sub processes in Flowable 6.

We haven't updated the BPMN editor yet with the ad-hoc sub process symbols and properties, as this is an Engine feature in its current state. But the editor part will be added as well of course. So let's imagine the following embedded sub process to be ad-hoc.

The ad-hoc sub process contains two tasks without any sequence flow being defined. When a process instance is started from this process definition, an ad-hoc sub process execution is created in the Flowable Engine and no user task is created yet. For an ad-hoc sub process you can get a list of enabled activities, which refers to the activities that are available within the ad-hoc sub process to work on. So you can work on Task 1 and Task 2 in any order. With the following API call you can get a list of enabled activities from the Engine.


This gives back a list of FlowNode objects that are enabled in the ad-hoc sub process for which the execution identifier is passed as parameter. In this example there will be two UserTask objects returned by this API call. So you can imagine a UI / application where a user can choose which task to work on next. The API call to start one of these tasks looks like this:

runtimeService.executeActivityInAdhocSubProcess(executionId, id);

So again the execution identifier of the ad-hoc sub process is provided, and in addition an identifier of the user task to select is provided as well. This identifier matches the id attribute of the user task element in the BPMN XML of the process definition. When this call is executed for Task 1 for example, the Flowable Engine will create a new user task, which will be available just like any other user task. 

An ad-hoc sub process by default can execute multiple enabled activities at the same time. This is defined with the ordering attribute in the BPMN XML definition. This means that we could also execute Task 2 in our example, while also having Task 1 active at the same time.

And what happens when Task 1 and/or Task 2 are completed. Without defining a completionCondition attribute in the BPMN XML, the Flowable Engine will not end the ad-hoc sub process execution automatically. The RuntimeService API provides the following method to complete an ad-hoc sub process when there are no active child executions (for example user tasks) anymore:


After invoking this method our example process will continue to the After task activity and the ad-hoc sub process will be ended.

But invoking a method to complete an ad-hoc sub process isn't appropriate for a lot of use cases. So let's look at an BPMN XML example with a defined completion condition.

<adHocSubProcess id="adhocSubProcess" ordering="Sequential">
    <userTask id="subProcessTask" name="Task in subprocess" />
    <userTask id="subProcessTask2" name="Task2 in subprocess" />


There are two differences with the previous example process definition. The first difference is the ordering attribute, which is set to Sequential. This means that only one of the user tasks can be executed at the same time. The Flowable Engine will not allow a second user task to be executed, when the first user task hasn't been completed yet. The second difference is the completion condition. This ad-hoc sub process will be automatically completed when the ${completed} expression evaluates to true. So, when we execute the first user task in the ad-hoc sub process and complete it together with a variable completed of true, the ad-hoc will end automatically after completing the user task.

Until now we have been demonstrating individual user tasks within an ad-hoc sub process only. But it's also possible to define individual task together with flows as well. Let's look at an example process model.

In this example Task 1 and Task 2 are enabled when the ad-hoc sub process is started by the Flowable Engine. So it's not possible to execute the other user tasks yet. When Task 1 is executed and completed, the Next task will be automatically created by the Engine, just like it would happen in a normal flow in a process definition. Using the completion condition, you can still determine when the ad-hoc sub process can be completed. And using the cancelRemainingInstances attribute it's possible to define whether the ad-hoc sub process should cancel any remaining executions / tasks when the completion condition evaluates to true. By default the Flowable Engine will cancel all other running executions / tasks, but when setting this attribute to false, the ad-hoc sub process will not complete before all executions / tasks have been ended.

The Flowable 6 Engine opens up a whole new range of dynamic behaviour in process instances. Because of its well defined execution structure and flexible API, there are a lot of new possibilities to add to the Engine. Ad-hoc sub processes is just an example as you will see more functionality appearing in Flowable 6 in the near future.

You can already play around with the ad-hoc sub process functionality on the master branch on Github (https://github.com/flowable/flowable-engine). We are looking for feedback from the community about this feature and other BPMN related features you would like to see implemented in Flowable 6.


  1. Hello Tijs,

    This looks very interesting and as I think through it I have got a few questions in my mind.
    Question 1
    Say I have 1 user task(assigned to user1) followed by adhoc sub process(all tasks assigned to user2) followed by another user task(assigned to user3). Here the user2 will not be knowing when he has to look for adhoc tasks assigned to him since he will not see him in his task inbox.
    Question 2
    Even though if he knows, I think he has to check for tasks by executionId which I think is process instance id which he might not be knowing.

    Question 3
    Even if he somehow gets to know the process instance Id, I think he should get the tasks related to each process instance id every time.

    Question 4
    Looking at the details, I think all the tasks in adhoc subprocess should be assigned to a single user. Am I right here ?

    I am sure you would thought thorough all these but its just that I am not clear and would like to know.


  2. Hi Hari,

    1. When an enabled user task in an ad-hoc sub process is executed the normal assignment logic is performed by the Engine, so no additional logic is needed there. The interesting bit is, how to execute an enabled user task. I think it makes sense to add some assignment logic on the adhoc sub process so an assignment-like query can be executed to get the "enabled" user tasks that you are allowed to execute.

    2. An easier query solution is needed, I agree. This is the only the first stage of ad-hoc sub process functionality.

    3. Don't understand this question, can you elaborate a bit?

    4. No, user tasks can have different assignment. When an enabled user task is executed the same assignment logic as with other user tasks is executed.

  3. Thanks for your quick reply Tijs.

    Reg Q1) Sorry, I cannot understand your answer here. In your post you said "an ad-hoc sub process execution is created in the Activiti Engine and no user task is created yet". So in my Q1, when usertask1 is completed, and since the user task 2 is not created yet as per the quoted text here. User2 will not be aware of UserTask1 completion and he will not look for enabled tasks. So my question is how will User2 know when to look for them.

    Reg Ans2) I do understand and I appreciate the efforts put in. I am sure we can see great things coming up out of this and we are waiting for them.

    Reg Q3) Say for example there are 10 instances of a process(which has adhoc sub process in it). Now when a user say User2 as per my example has to get the enabled tasks, he has to pass the executionid to the below snippet.


    So I think its not easy to get all the enabled tasks of all the process instances. The way I see is, he has to iterate through all the process instances and get the enabled tasks.

    To complicate the situation more, say for example there are 4 BPM's and 10+ instances of each of them which has adhoc sub process in them. And if User2 is involved in all 4 BPM's, to get a list of all enabled tasks in all the 4 BPM's 10+ instances could be a challenging.

    Is there an easier way to get them ?

    Reg Q4) Ok.


  4. Hi Hari,

    1. You need an additional query to look for enabled tasks for a user. So when you would you do this query user2 can be made aware by adding it to the task list or some other place.

    3. Not yet, but you are right that we need to a specific API to make this easy to do.

  5. how change the default databse in the activiti 6 Mysql to h2 Or how to connect activiti with mysql step by step

    1. Hi Ramzi,

      If you are having tomcat 9.0 in your system you can follow below path:
      Tomcat 9.0\webapps\activiti-explorer\WEB-INF\classes (For explorer)
      Tomcat 9.0\webapps\activiti-rest\WEB-INF\classes (For rest)
      Make your DB and host name edited as per your requirement


  6. Hi
    This new Element has support for callActivity, I mean, can I put an callAcitvity inside the Ad Doc subprocess
    Thanks :D

  7. Marco van Zwetselaar (zwets)August 20, 2017 at 9:57 AM

    Hi Tijs, I just tried modeling your example (using the modeler in 6.2.0-SNAPSHOT), but when I try to publish the App I get this error:

    "org.flowable.bpmn.exceptions.XMLException: cvc-complex-type.2.4.d: Invalid content was found starting with element 'userTask'. No child element is expected at this point."

    Would this mean the subprocess needs a (none) start event? Note the Userguide in 8.6.1 mentions "A Sub-Process can only have one none start event, no other start event types are allowed. A Sub-Process must at least have one end event. Note that the BPMN 2.0 specification allows the omission of the start and end events in a Sub-Process, but the current Flowable implementation does not support this."

  8. Marco van Zwetselaar (zwets)August 20, 2017 at 11:52 AM

    I have added a post on the Flowable forum[1] so as to have this documented 'centrally'.

    [1] https://forum.flowable.org/t/adhoc-task-fails-to-deploy/873

  9. Hi,
    This is interesting and i executed the sub process. But i have one question , Can I call one process from other process.( i have two processes A.bpmn20.xml and B.bpmn20.xml.can i call process B from Process A?.)

  10. 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.

    rpa Training in tambaram

    blueprism Training in tambaram

    automation anywhere training in tambaram

    iot Training in tambaram

    rpa training in sholinganallur

    blue prism training in sholinganallur

    automation anywhere training in sholinganallur

    iot training in sholinganallur

    1. The effectiveness of IEEE Project Domains depends very much on the situation in which they are applied. In order to further improve IEEE Final Year Project Domains practices we need to explicitly describe and utilise our knowledge about software domains of software engineering Final Year Project Domains for CSE technologies. This paper suggests a modelling formalism for supporting systematic reuse of software engineering technologies during planning of software projects and improvement programmes in Project Centers in Chennai for CSE.

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
      Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai

  11. Thanks for such a great article here. I was searching for something like this for quite a long time and at last I’ve found it on your blog. It was definitely interesting for me to read  about their market situation nowadays.
    Data Science Training in Chennai
    Data science training in bangalore
    Data science online training
    Data science training in pune
    Data Science training in kalyan nagar
    Data Science training in OMR
    selenium training in chennai

  12. 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 marathahalli | java training in btm layout

    java training in jayanagar | java training in electronic city

  13. Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
    python training in annanagar
    python training in chennai
    python training in chennai
    python training in Bangalore

  14. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.

    Devops training in sholinganallur

  15. We are a group of volunteers and starting a new initiative in a community. Your blog provided us valuable information to work on.You have done a marvellous job!
    Blueprism training in Chennai

    Blueprism online training

    Blue Prism Training in Pune

  16. 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.

    angularjs Training in chennai
    angularjs-Training in pune

    angularjs-Training in chennai

    angularjs Training in chennai

    angularjs-Training in tambaram

  17. 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

  18. Excellant post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.

    devops online training

    aws online training

    data science with python online training

    data science online training

    rpa online training

  19. This is quite educational arrange. It has famous breeding about what I rarity to vouch. Colossal proverb. This trumpet is a famous tone to nab to troths. Congratulations on a career well achieved. This arrange is synchronous s informative impolite festivity to pity. I appreciated what you ok extremely here.
    Microsoft Azure online training
    Selenium online training
    Java online training
    Python online training
    uipath online training

  20. Great post i must say and thanks for the information. I appreciate your post.

    ExcelR Data Science Bangalore

  21. This is also a very good post which I really enjoyed reading. It is not every day that I have the possibility to see something like this..
    ExcelR Data science courses in Bangalore

  22. It is perfect time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I desire to suggest you few interesting things or tips. Perhaps you could write next articles referring to this article. I want to read more things about it!


  23. Mmm.. good to be here in your article or post, whatever, I think I should also work hard for my own website like I see some good and updated working in your site.
    Data Science Course in Pune

  24. Really I Appreciate The Effort You Made To Share The Knowledge. This Is Really A Great Stuff For Sharing. Keep It Up . Thanks ForQuality posts is the crucial to invite the visitors to visit the web page, that's what this web page is providing. data science course in singapore

  25. I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!data science course in dubai

  26. thanks for sharing informative blog like this thank you so much.
    top 7 best washing machine

  27. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained!


  28. I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!
    How to Start A blog 2019
    Eid AL ADHA

  29. Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!
    data science course malaysia

  30. I was just browsing through the internet looking for some information and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject. Bookmarked this page, will come back for more.Data Science Courses

  31. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us
    You will get an introduction to the Python programming language and understand the importance of it. How to download and work with Python along with all the basics of Anaconda will be taught. You will also get a clear idea of downloading the various Python libraries and how to use them.
    About ExcelR Solutions and Innodatatics
    Do's and Don’ts as a participant
    Introduction to Python
    Installation of Anaconda Python
    Difference between Python2 and Python3
    Python Environment
    Exception Handling (Error Handling)
    Excelr Solutions

  32. Such a great and informative article.
    You just made my day thanks for sharing this article.

    data science course singapore is the best data science course

  33. I love your article so much. Good job
    ExcelR is a global leader delivering a wide gamut of management and technical training over 40 countries. We are a trusted training delivery partner of 350+ corporate clients and universities across the globe with 28,000+ professionals trained across various courses. With over 20 Franchise partners all over the world, ExcelR helps individuals and organisations by providing courses based on practical knowledge and theoretical concepts.

    Excelr Solutions

  34. I love your article so much. Good job
    Participants who complete the assignments and projects will get the eligibility to take the online exam. Thorough preparation is required by the participants to crack the exam. ExcelR's faculty will do the necessary handholding. Mock papers and practice tests will be provided to the eligible participants which help them to successfully clear the examination.

    Excelr Solutions

  35. It's really nice and meanful. it's really cool blog.you have really helped lots of people who visit blog and provide them useful information.
    data science course

  36. Nice Post...I have learn some new information.thanks for sharing.
    Click here for ExcelR Business Analytics Course

  37. I like you article. if you you want to saw Sufiyana Pyaar Mera Star Bharat Serials Full
    Sufiyana Pyaar Mera

  38. This is an awesome blog. Really very informative and creative contents. This concept is a good way to enhance the knowledge. Thanks for sharing.
    ExcelR business analytics course