Using CMMN Milestones and Sentries

The next step consists of adding a milestone. In CMMN, milestones express that a certain intermediate goal in the case has been reached. The condition(s) defining when the milestone is reached are modeled using Sentries.

Defining a Milestone

Go to the Camunda Modeler and create a new milestone from the palette. Double click on the milestone and name it Approved.

Defining a Sentry

Sentries are used to capture conditions within a case and can trigger other events to occur. We want to express that the Approved milestone is reached when both tasks have successfully completed, if the application was sufficient and if the customer received a good rating for creditworthiness.

First create a criterion on the milestone. Click on the Check Application task, then on the Append Criterion button in the context pad. Move the criterion to the right and place it on the milestone. Note how the criterion is attached to the milestone and an onPart connection is created with the complete standard event.

Now we want to connect the Provide Customer Rating task with the same sentry. Select the task and click on the Connect using Discretionary/OnPart or Association button. Move the mouse cursor and place the end of the connection on the sentry.

Now we can configure the two conditions (application sufficient and good rating) using the properties panel. Click on the sentry and type the following into the If Part Condition text input field: ${applicationSufficient && rating > 3}

Milestone Listener

Milestones are not visualized in the Camunda web applications. To see that the milestone occurs we add a CaseExecutionListener. Switch to Eclipse and in the project create a new Java class in the org.camunda.bpm.getstarted.cmmn.loanapproval package:

package org.camunda.bpm.getstarted.cmmn.loanapproval;

import java.util.logging.Logger;

import org.camunda.bpm.engine.delegate.CaseExecutionListener;
import org.camunda.bpm.engine.delegate.DelegateCaseExecution;

public class LifecycleListener implements CaseExecutionListener {

  private final static Logger LOGGER = Logger.getLogger("LOAN-REQUESTS-CMMN");

  public void notify(DelegateCaseExecution caseExecution) throws Exception {
    LOGGER.info("Plan Item '" + caseExecution.getActivityId() + "' labeled '"
        + caseExecution.getActivityName() + "' has performed transition: "
        + caseExecution.getEventName());
  }

}

Now this listener has to be registered with the milestone. To do that switch back to the Camunda Modeler. Click on the milestone and then on the Listeners tab in the properties panel. Now you can create a new Case Execution Listener with a click on the plus button to the right. A new Case Execution Listener with the event type occur and the type Java Class has been created. Configure the Java class by inserting the following into the Java Class text input field: org.camunda.bpm.getstarted.cmmn.loanapproval.LifecycleListener

Save the changes in the modeler before continuing.

Re-build and Deploy

When you are done, save all resources, perform a Maven build and redeploy the process application.

Hint to Maven

Before selecting the pom.xml in the Package Explorer of Eclipse and performing a right-click and select Run As / Maven Install, it is best practice to perform a right-click and select Run As / Maven Clean to make sure all resources are replaced with their newest version.

Now you can open the Tasklist and access the demo user’s tasks. First click on the task Check Application. Click on Add a variable. In the field Name, enter applicationSufficient. For Type, select Boolean. Make sure to tick the check box that now appears.

Click .

Next, complete the task Provide Customer Rating. Again, click on Add a variable and name the variable rating. Set the type to Integer and the value to 4. Click .

Now open the Tomcat console. You have completed the tasks and set the variables accordingly so that the milestone has occurred. On the console, you should see the following log entries:

INFO org.camunda.bpm.getstarted.cmmn.loanapproval.LifecycleListener
Plan Item 'PI_Milestone_1' labeled 'Approved' has performed transition: occur 

Our lifecycle listener has been notified, showing that the milestone has actually occurred.

Milestones

To learn more about milestones, consider checking the Milestone section in our CMMN implementation guide.

Catch up: Get the Sources of Step-5.

Download as .zip or checkout the corresponding tag with Git.

You can checkout the current state from the GitHub repository.

If you have not cloned the repository yet, please execute the following command:

git clone https://github.com/camunda/camunda-get-started-cmmn.git

To checkout the current state of the process application please execute the following command:

git checkout -f Step-5
Or download as archive from here.

On this Page: