Reputation: 9134
Background :
I have three bpmn diagrams
These are the service Tasks for them - screen shots
1. DMTMain.bpmn
2. DMTSub.bpmn
3. DMTTst.bpmn
First DMTMain.bpmn is called using the implementation mentioned in below Code#1.
For that, processId of DMTMain.bpmn is also passed.
Then in the MainMsg service task of the DMTMain.bpmn, we call DMTSub.bpmn using the startProcessInstanceByMessage() method as mentioned in below Code#2. (Note that DMTSub.bpmn is starting as a MessageEvent).
So, process starting in DMTSub.bpmn runs asynchronously as our expected behaviour. (That's why we used MessageStartEvent for DMTSub.bpmn)
Issue :
In our situation there can be various errors throwing from DMTTst.bpmn process including Camunda Engine related errors.
This is expected behavior as we are working on the caller framework (eg : including DMTMain and DMTSub etc).
So, the issue is, when the DMTTst.bpmn throws these like errors although they are caught at SubTst, only SubOut1 service task in DMTSub.bpmn executes after SubTst and it goes back to begining (SubParse) of the DMTSub.bpmn printing errors mentioned in Error#1 without executing SubOut2 and SubOut3.
This repeats exactly three times. It should be because of this and could be changed the retry with this
Expected behaviour :
If there are any error thrown from the DMTTst.bpmn, it should be able to catch at the SubTst (or equalant place) and proceed to SubOut2 and SubOut3 without going to the begining
Actually I know that we can invoke DMTTst.bpmn using CallActivity also. But we changed to this since we want to catch the exceptions.
Code #1
ProcessEngine defaultProcessEngine = BpmPlatform.getProcessEngineService().getDefaultProcessEngine();
RuntimeService runtimeService = defaultProcessEngine.getRuntimeService();
ProcessInstanceWithVariables processInstanceWithVariables = null;
try {
processInstanceWithVariables = runtimeService
.createProcessInstanceByKey(processId)
.setVariables(execution.getVariables())
.executeWithVariablesInReturn();
VariableMap variableMap = processInstanceWithVariables.getVariables();
} catch (Exception e) {
e.printStackTrace();
}
Code #2
public void execute(DelegateExecution execution) throws Exception {
try {
RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
runtimeService.startProcessInstanceByMessage("dmtSub", execution.getVariables());
} catch (Exception e) {
e.printStackTrace();
}
}
Error#1:
15:09:15,996 WARN [org.camunda.bpm.engine.jobexecutor] ENGINE-14006 Exception while executing job f1377b93-91d8-11ea-b41b-0242c2113c7d: : org.camunda.bpm.engine.ProcessEngineException: Process engine persistence exception at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.rethrow(CommandInvocationContext.java:151) at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:178) at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:116) at org.camunda.bpm.engine.impl.interceptor.JtaTransactionInterceptor.execute(JtaTransactionInterceptor.java:61) at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70) at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33) at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:51) ....
....
Caused by: java.sql.SQLException: IJ031070: Transaction cannot proceed: STATUS_MARKED_ROLLBACK at org.jboss.jca.adapters.jdbc.WrapperDataSource.checkTransactionActive(WrapperDataSource.java:248) at org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransactionActive(WrappedConnection.java:1933) at org.jboss.jca.adapters.jdbc.WrappedConnection.checkStatus(WrappedConnection.java:1948) at org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransaction(WrappedConnection.java:1922) at org.jboss.jca.adapters.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:452)
Edit :
Noted that this happens even we cal the DMTSub.bpmn through CallActivity or MessageEndEvent via normal service task.
And we have tried different ways like start DMTTst workflow with another process engine, catch the exception thrown in SubTst in Error End Event in DMTSub workflow also but no luck. Now trying options mentioned in here
Upvotes: 1
Views: 2044
Reputation: 9134
Found couple of approaches that close to the expected solution.
Control the retry :
You can control the retry by putting the failedJobRetryTimeCycle
property in your standalone.xml
file as mentioned below.
The pattern relevant to the ISO_8601 standard for repeating time intervals.
<property name="failedJobRetryTimeCycle">R0/PT5S</property>
Or you can specify that in the service task / start event itself using the Retry Time Cycle under Job Configuration
Catching error and continuation :
This can be done in two ways.
Call the DMTTst as a CallActivity and add a Boundry Error Event to that and let it flow through to the next task
Note : But in both cases better to add the Error Code as java.lang.Exception as mentioned below. Then it will catch any exception which is subclass of that. eg : Java exception, unrecognized BPMN property etc.
References :
Upvotes: 1