Message correlation when service task is in progress

Hi,
I have problem with interrupting subprocess using Message Boundary Event when my service task is in progress. Service task in the picture takes about 10 seconds and then subprocess is waiting for for response for 10 minutes. If no response received I have to execute service task again (loop). There is boundary event on whole subprocess “cancel message received”. Problem occurs when cancellation message arrives ( execution of correlate message from runtime service api) when service task is in progress. There is “Cannot correlate message exception” and process is still running. On the other hand I have also Timer Boundary Event on subprocess (“timeout”) and it works as expected - when timeout occurs during service task execution, execution of service task is finished and subprocess is stopped. Please give advice how to model that process correctly to achieve expected cancellation result.

camunda_process

Hi @kkedzierski87,

Could you please upload the complete stack trace of the exception.

Best regards,
Yana

@yana.vasileva - I’m including stack trace. When I’m sending the same CancelMessage when process is in “wait for response state” everything works fine.

2018-02-20 09:36:20.986 ERROR [task-processing,661a2f0fffecf6c7,661a2f0fffecf6c7,false] 5953 — [nio-8079-exec-3] org.camunda.bpm.engine.context : ENGINE-16004 Exception while closing command context: Cannot correlate message ‘CancelMessage’: No process definition or execution matches the parameters

org.camunda.bpm.engine.MismatchingMessageCorrelationException: Cannot correlate message ‘CancelMessage’: No process definition or execution matches the parameters
at org.camunda.bpm.engine.impl.cmd.CorrelateMessageCmd.execute(CorrelateMessageCmd.java:61)
at org.camunda.bpm.engine.impl.cmd.CorrelateMessageCmd.execute(CorrelateMessageCmd.java:36)
at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:104)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
at org.camunda.bpm.engine.impl.MessageCorrelationBuilderImpl.execute(MessageCorrelationBuilderImpl.java:240)
at org.camunda.bpm.engine.impl.MessageCorrelationBuilderImpl.correlateWithResult(MessageCorrelationBuilderImpl.java:184)
at org.camunda.bpm.engine.impl.MessageCorrelationBuilderImpl.correlate(MessageCorrelationBuilderImpl.java:176)
at eu.trans.freights.processing.camunda.cancel.UberProcessController.subProcessCancelation(UberProcessController.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.web2018-02-20 09:36:20.986 ERROR [task-processing,661a2f0fffecf6c7,661a2f0fffecf6c7,false] 5953 — [nio-8079-exec-3] org.camunda.bpm.engine.context : ENGINE-16004 Exception while closing command context: Cannot correlate message ‘CancelMessage’: No process definition or execution matches the parameters

After adding timer event before service task execution message correlation is possible and process is finished, but it seems that service task is still executing in the background and after few seconds I have exception:

2018-02-20 11:08:58.760 ERROR [task-processing,32abf28af6e5069f,32abf28af6e5069f,false] 25061 — [aTaskExecutor-3] org.mariadb.jdbc.MariaDbStatement : error executing query

java.sql.SQLIntegrityConstraintViolationException: (conn:3) Cannot add or update a child row: a foreign key constraint fails (camunda.ACT_RU_EXECUTION, CONSTRAINT ACT_FK_EXE_PROCINST FOREIGN KEY (PROC_INST_ID_) REFERENCES ACT_RU_EXECUTION (ID_) ON DELETE CASCADE ON UPDATE CASCADE)
Query is : insert into ACT_RU_EXECUTION
(
ID_,
PROC_INST_ID_,
BUSINESS_KEY_,
PROC_DEF_ID_,
ACT_ID_,
ACT_INST_ID_,
IS_ACTIVE_,
IS_CONCURRENT_,
IS_SCOPE_,
IS_EVENT_SCOPE_,
PARENT_ID_,
SUPER_EXEC_,
SUPER_CASE_EXEC_,
CASE_INST_ID_,
SUSPENSION_STATE_,
CACHED_ENT_STATE_,
SEQUENCE_COUNTER_,
TENANT_ID_,
REV_
)
values
(
‘1129078a-1626-11e8-8c07-4afac8e2e763’,
‘f93ebec5-1625-11e8-8c07-4afac8e2e763’,
NULL,
‘process_timeout_test:1:e18068f9-1625-11e8-8c07-4afac8e2e763’,
‘Task_1lkhgbf2’,
‘Task_1lkhgbf2:11292e9c-1626-11e8-8c07-4afac8e2e763’,
1,
0,
1,
0,
‘fc3f067a-1625-11e8-8c07-4afac8e2e763’,
NULL,
NULL,
NULL,
1,
5,
16,
NULL,
1
)
at org.mariadb.jdbc.internal.util.ExceptionMapper.get(ExceptionMapper.java:133)
at org.mariadb.jdbc.internal.util.ExceptionMapper.getException(ExceptionMapper.java:101)
at org.mariadb.jdbc.internal.util.ExceptionMapper.throwAndLogException(ExceptionMapper.java:77)
at org.mariadb.jdbc.MariaDbStatement.executeQueryEpilog(MariaDbStatement.java:226)
at org.mariadb.jdbc.MariaDbClientPreparedStatement.executeBatch(MariaDbClientPreparedStatement.java:304)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:122)
at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:129)
at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:122)
at org.apache.ibatis.executor.CachingExecutor.flushStatements(CachingExecutor.java:114)
at org.apache.ibatis.session.defaults.DefaultSqlSession.flushStatements(DefaultSqlSession.java:253)
at org.camunda.bpm.engine.impl.db.sql.DbSqlSession.flushOperations(DbSqlSession.java:88)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperations(DbEntityManager.java:341)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperationManager(DbEntityManager.java:314)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flush(DbEntityManager.java:286)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:203)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:132)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:113)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:36)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:29)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.executeJob(ExecuteJobsRunnable.java:88)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:57)
at org.springframework.cloud.sleuth.instrument.async.SpanContinuingTraceRunnable.run(SpanContinuingTraceRunnable.java:52)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.mariadb.jdbc.internal.util.dao.QueryException: Cannot add or update a child row: a foreign key constraint fails (camunda.ACT_RU_EXECUTION, CONSTRAINT ACT_FK_EXE_PROCINST FOREIGN KEY (PROC_INST_ID_) REFERENCES ACT_RU_EXECUTION (ID_) ON DELETE CASCADE ON UPDATE CASCADE)
Query is : insert into ACT_RU_EXECUTION
(
ID_,
PROC_INST_ID_,
BUSINESS_KEY_,
PROC_DEF_ID_,
ACT_ID_,
ACT_INST_ID_,
IS_ACTIVE_,
IS_CONCURRENT_,
IS_SCOPE_,
IS_EVENT_SCOPE_,
PARENT_ID_,
SUPER_EXEC_,
SUPER_CASE_EXEC_,
CASE_INST_ID_,
SUSPENSION_STATE_,
CACHED_ENT_STATE_,
SEQUENCE_COUNTER_,
TENANT_ID_,
REV_
)
values
(
‘1129078a-1626-11e8-8c07-4afac8e2e763’,
‘f93ebec5-1625-11e8-8c07-4afac8e2e763’,
NULL,
‘process_timeout_test:1:e18068f9-1625-11e8-8c07-4afac8e2e763’,
‘Task_1lkhgbf2’,
‘Task_1lkhgbf2:11292e9c-1626-11e8-8c07-4afac8e2e763’,
1,
0,
1,
0,
‘fc3f067a-1625-11e8-8c07-4afac8e2e763’,
NULL,
NULL,
NULL,
1,
5,
16,
NULL,
1
)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readErrorPacket(AbstractQueryProtocol.java:1144)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readPacket(AbstractQueryProtocol.java:1076)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:1031)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeBatchRewrite(AbstractQueryProtocol.java:424)
at sun.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mariadb.jdbc.internal.logging.ProtocolLoggingProxy.invoke(ProtocolLoggingProxy.java:106)
at com.sun.proxy.$Proxy85.executeBatchRewrite(Unknown Source)
at org.mariadb.jdbc.MariaDbClientPreparedStatement.executeInternalBatch(MariaDbClientPreparedStatement.java:340)
at org.mariadb.jdbc.MariaDbClientPreparedStatement.executeBatch(MariaDbClientPreparedStatement.java:297)
… 27 common frames omitted

For me it looks like a bug… Expected behaviour is that flow is waiting for the end of service task ececution and then it’s going out of suprocess. Am I right that it’s bug or I have to do something in different way?

Hi @kkedzierski87,

Can you please provide a test case reproducing this? You can use the following project to get started:

Best regards,
Yana