Hello Everyone,
I am trying to create a flow through camunda for a multi-store order where the flow for each store is a sub-process. This process is started with the orderId and each sub-process is started with the shopId from the shops collection.
orderflow1stDraft.bpmn (38.3 KB)
My requirement is to create a Rest API on camunda-spring-boot deployement itself, This API is not being called by the process itself so it is not an extension of JavaDelegates and I do not have access to execution context. I have to do it through RespositoryService.
This API will take orderId and shopId as input and provide me with the below output.
-
On which IntermediateCatchEvent (and Global Message Name) the processInstance for the provided orderId and shopId is waiting on.
-
The Succeeding Service Task Node of this IntermediateCatchEvent and it’s input parameters
-
History of Service Tasks Nodes and their input parameters values up until reaching this IntermediateCatchEvent.
Tried sloution for problem 1:
I used the below code to get the active activity ids.
ProcessInstance instances = runtimeService.createProcessInstanceQuery()
.variableValueEquals("orderId", order.getOrderId()).singleResult();
instanceId = instance.getProcessInstanceId();
List<String> taskDefinitionKeys = runtimeService.getActiveActivityIds(instanceId);
But, this gives me all active activity Ids of all the sub-process for all shopIds in that orderId like [“Event_1pphxk1”, “Event_1b0pqcb”].
How do I get the active activity id of the sub-process that I want?
If not, how do I get the input parameter variables from this activity with id Event_1pphxk1 and make comparisions?
To solve the 2nd Problem I tried the below code
BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processId);
ModelElementInstance currentActivityInstance = modelInstance.getModelElementById(taskDefinitionKey);
IntermediateCatchEvent messageTask = (IntermediateCatchEvent) currentActivityInstance
List<ServiceTask> nextTasks = messageTask.getSucceedingNodes().filterByType(ServiceTask.class).list();
This too gives me the activityIds like Activity_1hx194z. How do I extract some variables(local subprocess and input) from it?
Have not tried the 3rd problem yet as stuck on these 2.
Any solution or code snippet examples will be much appriciated.
Here is my Java class for the API.
CamundaController.txt (7.8 KB)
Thanks.
Avakash