How to implement transaction subprocess using Camunda's fluent builder API?

Viewed 277

Hello I am trying to implement transaction sub-process using the Fluent Builder API. I suspect it is this:

builder.transaction(subprocessId)

but firstly transaction method returns TransactionBuilder which does not have method for adding start event. Why does it not contain this method? How am I supposed to add the start event? Then when I am trying (even immedietly after opening the transaction) to call the method transactionDone() the deployment tells me it cannot find parent transaction. Lastly when trying to end cancel event inside the transaction deployment tells me that cancel event can be only inside transaction subprocess. What am I doing wrong? Can someone please give me an example of how to implement transaction subprocess using fluent builder API?

1 Answers

After creating the transaction you could continued to build the parent process or build out the embedded sub process (transaction). To enter the scope of the embedded sub process use

.transaction().embeddedSubProcess()

With .transactionDone() or .subProcessDone() one can subsequently step back into the scope of the parent process.

Full Example: https://github.com/rob2universe/bpmn-creator/blob/cbc4be80e1c1c821f51feba63ff1d1b62c19769f/src/main/java/TransactionSubprocess.java#L28

Documentation (search for subProcess): https://docs.camunda.org/manual/latest/user-guide/model-api/bpmn-model-api/fluent-builder-api/

This answers the sub process question, but next you may be searching for the Cancel event on the API. This does not seem to be covered by fluent API yet. Signal, Message, Compensation are there (e.g. .compensateEventDefinition())

However, you can still create a CancelEventDefinition and add it to the end event via the regular API as shown in this example: https://github.com/rob2universe/bpmn-creator/blob/cbc4be80e1c1c821f51feba63ff1d1b62c19769f/src/main/java/TransactionSubprocess.java#L37

Related