Listening on Camunda transactions to be able to send events

Hi,

we want to send messages (Publish/Subscribe) whenever Camunda Engine has changed something. As we do not want to spam to this topic, we had the idea to publish only when Camunda has completed a transaction to send a message like this:

“I have changed the process with processInstanceId X. That’s the process with your correlation variable A=123 and B = 678. (Feel free to fetch updated data)”

Better would be:

“I have changed the process with processInstanceId X OR a subprocess. That’s the process with your correlation variable A=123 and B = 678. (Feel free to fetch updated data)”

What would be the best approach to solve this?

Best Regards,
Michael

Hi Michael,

you can use an execution listener. It is triggered when a process instance / execution is changed. If you need more (e.g. variable changes) then you can implement a custom history event handler.
If you need to be aware of the transaction then you can collect the events and register a TransactionSynchronisationListener which pushes the events on commit.

Context.getCommandContext().getTransactionContext().addTransactionListener(TransactionState.COMMITTED, txListener);

Does this help you?

Best regards,
Philipp