process.isEnded always returns false

509 views
Skip to first unread message

Thomas Winkler

unread,
Apr 8, 2013, 3:19:02 PM4/8/13
to camunda-...@googlegroups.com
Hi,

we are currently building up a system using a workflow engine for massive data processing and recently started using Camunda BPM.  When unit testing some exmaple workflows I found out that the process instance I was testing always returned false when invoking process.isEnded() even the endpoint has been reached.

So my question is wether a process instance is set to isEnded == true just when an EndEvent is reached or is there something else required?

I did not yet fully dig into the source code, but this would be my next try...

If required I can post a code example as well if required.

Thanks in advance,

Thomas

Bernd Rücker (camunda)

unread,
Apr 8, 2013, 3:28:59 PM4/8/13
to Thomas Winkler, camunda-...@googlegroups.com

Hi Thomas.

 

A test case (+ bpmn 2 xml) would indeed help to understand your case. Now I can only guess – let me try ;-)

 

If a process instance runs through till the end it is removed from the runtime database and only exists in the history database afterwards (I hope you don’t mind if I quote old camunda fox docs – which are not yet migrated: https://app.camunda.com/confluence/display/foxUserGuide/History#History-Overview). So you have to query the process instance from the history to check if it is ended (or check if a query on the runtime returns no result).

 

A typical testcase would do something like this: https://github.com/camunda/camunda-bpm-platform/blob/master/examples/invoice/src/test/java/org/camunda/bpm/example/invoice/InvoiceTestCase.java

 

And this checks for completion at the end via:

  public static void assertProcessEnded(ProcessEngine processEngine, String processInstanceId) {

    ProcessInstance processInstance = processEngine

      .getRuntimeService()

      .createProcessInstanceQuery()

      .processInstanceId(processInstanceId)

      .singleResult();

   

    if (processInstance!=null) {

      throw new AssertionFailedError("expected finished process instance '"+processInstanceId+"' but it was still in the db");

    }

  }

 

Hope that helps

Cheers

Bernd

--
You received this message because you are subscribed to the Google Groups "camunda BPM users & process application developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.
 
 

Thomas Winkler

unread,
Apr 9, 2013, 7:44:34 AM4/9/13
to camunda-...@googlegroups.com, Thomas Winkler
Hi Bernd,

that was exactly I was looking for!

Thanks for the quick response
Reply all
Reply to author
Forward
0 new messages