I want to keep track of the status of my Flowable processes ( which I invoke through REST call) i.e. I want to know, which process started when and when it finished , and if it has NOT finished then at which step is it.
The way, am doing it is by firing a query on ACT_HI_ACTINST with the PROC_INST_ID_ ( I get this id in the response of the REST call, through which I trigger the process). e.g.
SELECT * FROM flowable.ACT_HI_ACTINST where PROC_INST_ID_ like ‘517708’.
The above query gives the names of all the Steps (ACT_NAME_ & ACT_ID_) which were executed for this process instance.
I want to create multiple processes , which would shared same steps , is there a way to create a global ACT_ID_ which can be used by multiple processes ? e.g. I want to have a service-task with one Id which no other service-task can have ( like a primary key). Currently, I can have multiple service-tasks with the same id.
Thanks in advance for your suggestions/help.
The ACT_ID_ value is filled with the id attribute of the serviceTask element in the BPMN XML. So if you consistently use the same id attribute for same service task in different BPMN XMLs it will have the same ACT_ID_ value. Within the same process definition / BPMN XML you can only use an id attribute value once, because it needs to be unique within the BPMN XML.
Thanks @tijs. Yes that what even my understanding is. But the issue is what if someone gives the same ID to a different serviceTask which is not meant to be same thing, as the one it is intended to be i.e. I want a way to restrict the user from using the Id in a wrong way . So am planning to keep track of the status of each step in my own DB.
i.e. if my process has 5 different Service-Tasks (each considered as 1 step), then after each step is done, I would mark it as Complete in my DB. My question to you is that from a best practice perspective would the use of Execution-Listener is correct in this case i.e. I would execute a listener (which would make a DB call) at the end of each Step ? Or should I have a service-task after each step to update the status of it in DB ?
In case you want to avoid using certain ids you can either hook in a custom BpmnParseHandler or add a custom validator. Both are called when the process definition is deployed.
Not sure why you’d want a complete in the db yourself, the historical data already contains that. However, if you do want to do it yourself, an executionlistener would indeed be the way to go (or have a custom ActivityBehaviorFactory that wraps the original behaviour)
Thanks @joram . Would do try with it.
@joram @tijs another question , from ACT_HI_ACTINST table am able to find the status of the steps executed in a process i.e. if a process has 10 steps and 5 of these steps and done and 6th step is waiting for something to happen before it can execute then ACT_HI_ACTINST would have the entries till Step-5 with Start/End time. My question is where I can find the FULL mapping for the entire process irrespective of the execution status.
You can get a java representation of the whole proces definition through the repositoryService.getBpmnModel(processDefinitionId) method.
Thanks @joram. I was actually looking for it from the DB perspective i.e. which table to look for to get the entire mapping .
The whole mapping is not stored in a relational way, as there’s no need for that. Rather, the BPMN model xml is stored in in a table (ACT_GE_BYTEARRAY), and fetched from the database to parse to an executable java model when neeed.
Thanks @joram for sharing the details.