Hi everyone,
I am currently building a process instance that is in its heart an orchestration of a number of services and functions. Hence, my processes will be enriched with data along the way of the process model.
In this context I was wondering if there are any best practices (or common pitfalls to avoid) for the design of data models for process instances in Camunda?
Best Regards
Marius
Hi @marius_b,
take a look here: Real-world BPMN 2.0 examples and answers to common questions. | Camunda this explains a lot about “how to model a process”.
This covers modelling. Then comes the technical part, from my perspective, there are two key concepts to keep in mind when implementing a model properly:
- Make a good use of businessKey - the business key should reflect the object that is being processes, for example, if you are modeling a document processing, the businessKey would be a unique identifier of that document.
- Avoid process variables - one of common pitfalls is putting everything in process variables. If you are storing a document, lets say in mongo, and this document has a flag “approved”, you don’t want to duplicate this kind of information in process variable, because once the flag changes, you will have to update the variable as well. This is data duplication and forces you to create some complex synchronisation mechanisms. Best way to avoid it is to store business data in dedicated storage (in this example, its mongo), and keep the id of the mongo document as a variable (this will be unique and immutable reference to source of truth), then, whenever you want to access the data, do it via java delegate and the id variable from the process. This will make your data consistent.
There are multiple more smaller pitfalls, but if you design your process model correctly, as per link shared, and apply the two points I mentioned, you will be fine.