I want to catch an error (e.g. RuntimeException) by an Error Boundary Event attached to my init-job Service Task. This works, when the requestAsyncJob() Method throws some RuntimException.
But since it’s asynchronous, it’s also possible, that the external sytems sends us after the method completion a failure (we trigger() then the execution with a variable status=error), and we would also like to enter the Error Boundary Event. Currently we have some ‘Callback’ ExecutionListeners for examing the status variable and throwing exceptions when status=error so that the execution stops.
But throwing the RuntimeException in the ExecutionListener does not propagate the error, also calling ErrorPropagation.propagateError(“some-error”, execution) inside there does not work.
Any ideas how to come around this issue by using expressions (not delegateExpressions)?
ok, no reply, not sure, whether my question was unclear or too complicated !?
So, I found following working solution:
I extend org.flowable.engine.impl.bpmn.behavior.ServiceTaskExpressionActivityBehavior and overwrite trigger() by implementing the Error-propagation inside there.
Next problem: How to create a DeadLetter Job, when the callback is reportet as error (this does not happen)?
I tried following code, which is executed without exception but the DB table ACT_RU_DEADLETTER_JOB is empty:
I agree. If the error propagation isn’t done there, it should be added. I’ll check if I can add this to the code.
No, that code looks correct.
Can you enable debug logging and check whether either the deadletter job gets inserted (doubtful) or there is a transaction rollback? In the second case, the deadletter job should then be created in a post-rollback listener that you can attach to the currect TransactionContext (which you can retrieve via the Context class).