I have a process that has two end states. When the abnormal end state is reached (via a message), calls to:
runtimeService.createProcessInstanceQuery().processInstanceId(instanceId).singleResult().isEnded()
returns false.
I would have expected this to return true. In other words, only on end state has to be reached, right?
Here is my diagram:
http://www.camunda.org/share/#/process/a11dc80e-dc7b-4d72-aa53-465eeb33af05
Also, I see in the database:
mysql> select * from act_hi_actinst where proc_inst_id_=5301 order by start_time_ asc;
+-------------------------+---------------------+-----------------------------------+---------------+---------------+--------------------+----------+--------------------+--------------------------------------+------------------+-----------+---------------------+---------------------+-----------+
| ID_ | PARENT_ACT_INST_ID_ | PROC_DEF_ID_ | PROC_INST_ID_ | EXECUTION_ID_ | ACT_ID_ | TASK_ID_ | CALL_PROC_INST_ID_ | ACT_NAME_ | ACT_TYPE_ | ASSIGNEE_ | START_TIME_ | END_TIME_ | DURATION_ |
+-------------------------+---------------------+-----------------------------------+---------------+---------------+--------------------+----------+--------------------+--------------------------------------+------------------+-----------+---------------------+---------------------+-----------+
| StartEvent_1:5302 | 5301 | cam_parallel_camel_rucker:19:5015 | 5301 | 5301 | StartEvent_1 | NULL | NULL | NULL | startEvent | NULL | 2013-11-20 15:44:22 | 2013-11-20 15:44:22 | 0 |
| ServiceTask_1:5309 | 5301 | cam_parallel_camel_rucker:19:5015 | 5301 | 5308 | ServiceTask_1 | NULL | NULL | call camel route 1 | serviceTask | NULL | 2013-11-20 15:44:22 | 2013-11-20 15:44:22 | 21 |
| ParallelGateway_1:5303 | 5301 | cam_parallel_camel_rucker:19:5015 | 5301 | 5305 | ParallelGateway_1 | NULL | NULL | first parallel gateway | parallelGateway | NULL | 2013-11-20 15:44:22 | 2013-11-20 15:44:22 | 3 |
| ServiceTask_2:5316 | 5301 | cam_parallel_camel_rucker:19:5015 | 5301 | 5315 | ServiceTask_2 | NULL | NULL | call camel route 2 | serviceTask | NULL | 2013-11-20 15:44:23 | 2013-11-20 15:44:23 | 3 |
| EndEvent_2:5323 | 5301 | cam_parallel_camel_rucker:19:5015 | 5301 | 5304 | EndEvent_2 | NULL | NULL | abnormal end | endEvent | NULL | 2013-11-20 15:44:31 | 2013-11-20 15:44:31 | 0 |
| ScriptTask_7:5322 | 5301 | cam_parallel_camel_rucker:19:5015 | 5301 | 5304 | ScriptTask_7 | NULL | NULL | log second part of camel route error | scriptTask | NULL | 2013-11-20 15:44:31 | 2013-11-20 15:44:31 | 22 |
| ScriptTask_3:5324 | 5301 | cam_parallel_camel_rucker:19:5015 | 5301 | 5301 | ScriptTask_3 | NULL | NULL | log that msg 2 received | scriptTask | NULL | 2013-11-20 15:44:42 | 2013-11-20 15:44:42 | 5 |
| ParallelGateway_2:5326 | 5301 | cam_parallel_camel_rucker:19:5015 | 5301 | 5301 | ParallelGateway_2 | NULL | NULL | joining parallel gateway | parallelGateway | NULL | 2013-11-20 15:44:42 | NULL | NULL |
| ExclusiveGateway_1:5325 | 5301 | cam_parallel_camel_rucker:19:5015 | 5301 | 5301 | ExclusiveGateway_1 | NULL | NULL | xor gate 2 | exclusiveGateway | NULL | 2013-11-20 15:44:42 | 2013-11-20 15:44:42 | 0 |
+-------------------------+---------------------+-----------------------------------+---------------+---------------+--------------------+----------+--------------------+--------------------------------------+------------------+-----------+---------------------+---------------------+-----------+
9 rows in set (0.00 sec)
As you can see, the "abnormal end" endEvent has both a start time and an end time, indicating that it has run.
My code looks like this:
// Wait for process to run to completion...
//
while (true) {
ProcessInstance processInstance =
runtimeService.createProcessInstanceQuery()
.processInstanceId(instanceId).singleResult();
if (processInstance == null) {
log.info("PROCESS ["+instanceId+"] DOES NOT EXIST ANYMORE");
break;
}
else if (processInstance.isEnded()) {
log.info("PROCESS ["+instanceId+"] ENDED");
break;
}
else {
log.info("PROCESS["+processInstance.getProcessInstanceId()+"] (suspended="+processInstance.isSuspended()+", ended="+processInstance.isEnded()+")");
}
try { Thread.sleep(2000); } catch (InterruptedException e) { ; }
}
and the output looks like this:
03:44:22,447 [http-8080-1] INFO controller.ProcessController - **************** STARTED process 'cam_parallel_camel_rucker' ID = 5301
03:44:22,447 [http-8080-1] INFO service.camunda.CamundaExecutionService - Waiting for Camunda process instance '5301' to finish...
03:44:22,463 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
Thread[pool-1-thread-1,5,main]1: FORWARDING TO runStuff1
Thread[Camel (camelContext) thread #5 - seda://runStuff1,5,main]1: SLEEPING FOR 8880 ms...
Thread[pool-1-thread-1,5,main]!!!!!!! 2: FORWARDING TO runStuff2
Thread[Camel (camelContext) thread #6 - seda://runStuff2,5,main]2: SLEEPING FOR 19207 ms...
03:44:24,472 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:26,482 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:28,490 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:30,498 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
Thread[Camel (camelContext) thread #5 - seda://runStuff1,5,main]1: DONE WITH SLEEP
03:44:31,376 [Camel (camelContext) thread #5 - seda://runStuff1] INFO routes.camunda.CamundaCamelRoutes - 1: Throwing post-sleep error
ERROR Second part of camel route.
03:44:31,443 [Camel (camelContext) thread #5 - seda://runStuff1] ERROR org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-ghollins on ExchangeId: ID-ghollins). Exhausted after delivery attempt: 1 caught: routes.camunda.SampleException: 1: simulated error (post-sleep). Processed by failure processor: FatalFallbackErrorHandler[Channel[sendTo(Endpoint[camunda-bpm://message?messageName=camel.error1])]]
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)
[route2 ] [route2 ] [seda://runStuff1 ] [ 8953]
[route1 ] [process1 ] [ routes.camunda.CamundaCamelRoutes$1@459bdb65 ] [ 4]
[route1 ] [to1 ] [seda:runStuff1?waitForTaskToComplete=Never ] [ 1]
[route2 ] [process2 ] [ routes.camunda.CamundaCamelRoutes$2@4bcd2d49 ] [ 8945]
[route2 ] [to2 ] [camunda-bpm:message?messageName=camel.error1 ] [ 62]
Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
Id ID-ghollins
ExchangePattern InOut
Headers {breadcrumbId=ID-ghollins, CamelRedelivered=false, CamelRedeliveryCounter=0}
BodyType java.util.HashMap
Body {}
]
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
routes.camunda.SampleException: 1: simulated error (post-sleep)
at routes.camunda.CamundaCamelRoutes$2.process(CamundaCamelRoutes.java:102)
at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:291)
at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:200)
at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:147)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
03:44:31,445 [Camel (camelContext) thread #5 - seda://runStuff1] WARN org.apache.camel.component.seda.SedaConsumer - Error processing exchange. Exchange[Message: {}]. Caused by: [ routes.camunda.SampleException - 1: simulated error (post-sleep)]
routes.camunda.SampleException: 1: simulated error (post-sleep)
at routes.camunda.CamundaCamelRoutes$2.process(CamundaCamelRoutes.java:102)
at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:291)
at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:200)
at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:147)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
03:44:32,507 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:34,514 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:36,522 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:38,530 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:40,538 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
Thread[Camel (camelContext) thread #6 - seda://runStuff2,5,main]2: DONE WITH SLEEP
msg 2 received.
03:44:42,545 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:44,552 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:46,558 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:48,565 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:50,571 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:52,581 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:54,588 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
03:44:56,595 [http-8080-1] INFO service.camunda.CamundaExecutionService - PROCESS[5301] (suspended=false, ended=false)
...
...
<<<OUTPUT KEEPS GOING...>>>
I'm not exactly sure why I get the " Failed delivery for" error, as the message does indeed get received by the process. Otherwise it wouldn't have got to the end state.
Perhaps related to:
https://groups.google.com/forum/#!msg/camunda-bpm-users/DHFL-2e8GKg/UYZEjy_IcdgJ
Thanks,
Galen
However, I still get the "Failed delivery" errors in the logs...
Thanks,
Galen