Hi,
Thanks for elaboration. I believe there is no good alternative for your case that is less messy.
I’ll try to respond to some aspects as good as possible:
- The way you adapted the code looks good (i.e. by using
processEngineConfiguration#getCommandExecutorTxRequired) - It should not be required to alter the command executor in any way
- If you need additional custom logic executed in a transaction, there are different options. The most safe one (i.e. using public API) would be to use transaction integration via Spring or JTA. The non-public API approach that works in any environment is via
CommandExecutor#executeCommand. Inside the command (argument to aforementioned method), you can execute any code that accesses the database or even invoke other commands (e.g. a query is a command). These will all be executed in the same transaction. Again, this is not public API and is therefore not documented and can change any time. - Lastly, we would like to remove the tutorial from the official documentation as described here: https://app.camunda.com/jira/browse/CAM-4845. The reason is that this tutorial uses internal API heavily and links to code that is maintained outside of the Camunda product space (https://github.com/camunda/camunda-consulting is not maintained by the Camunda product team). This results in outdated documentation and inconsistencies between docs and code, which is a not a great experience for anyone trying to follow along. That’s also why we won’t update the docs for now. I’m sorry for the messy documentation in this area.
Cheers,
Thorben