Skip to main content

In this step, we use Java Code to evaluate the decision table. Then we deploy the web application to Apache Tomcat and verify the result in Cockpit.

Evaluate the Decision Table

To directly evaluate the decision table after deployment, add the following method to your Application class:

package org.operaton.bpm.getstarted.dmn;

@ProcessApplication("Dinner App DMN")
public class DinnerApplication extends ServletProcessApplication {

protected final static Logger LOGGER = Logger.getLogger(DinnerApplication.class.getName());

@PostDeploy
public void evaluateDecisionTable(ProcessEngine processEngine) {

DecisionService decisionService = processEngine.getDecisionService();

VariableMap variables = Variables.createVariables()
.putValue("season", "Spring")
.putValue("guestCount", 10);

DmnDecisionTableResult dishDecisionResult = decisionService.evaluateDecisionTableByKey("dish", variables);
String desiredDish = dishDecisionResult.getSingleEntry();

LOGGER.log(Level.INFO, "\n\nDesired dish: {0}\n\n", desiredDish);
}

}

Build the Web Application with Maven

Select the pom.xml in the Package Explorer, perform a right-click and select Run As / Maven Install. This will generate a WAR file named dinner-dmn-0.1.0-SNAPSHOT.war in the target/ folder of your Maven project.

Hint

If the dinner-dmn-0.1.0-SNAPSHOT.war file is not visible after having performed the Maven build, you need to refresh the project (F5) in eclipse.

Deploy to Apache Tomcat

In order to deploy the process application, copy-paste the dinner-dmn-0.1.0-SNAPSHOT.war from your Maven project to the $CAMUNDA_HOME/server/apache-tomcat/webapps folder.

Check the log file of the Apache Tomcat server. If you see the following log message, the deployment was successful:

INFO org.operaton.commons.logging.BaseLogger.logInfo ENGINE-07015 Detected @ProcessApplication class 'org.operaton.bpm.getstarted.dish.DishApplication' INFO org.operaton.commons.logging.BaseLogger.logInfo ENGINE-08024 Found processes.xml file at ../webapps/dinner-dmn-0.1.0-SNAPSHOT/WEB-INF/classes/META-INF/processes.xml INFO org.operaton.commons.logging.BaseLogger.logInfo ENGINE-08023 Deployment summary for process archive 'dinner-dmn':

dinnerDecisions.dmn

INFO org.operaton.bpm.getstarted.dmn.DinnerApplication.evaluateDecisionTable

Desired dish: Stew

INFO org.operaton.commons.logging.BaseLogger.logInfo ENGINE-08050 Process application Dinner App DMN successfully deployed

Verify the Deployment with Cockpit

Now, use Cockpit to check if the decision table is successfully deployed. Go to http://localhost:8080/operaton/app/cockpit. Log in with demo / demo. Go to "Decisions" section. Your decision table Dish should be listed as deployed decision definition.

Example image

Verify the Evaluation with Cockpit

Click on the decision Dish. This opens a dialog where you see when the decision table was evaluated.

Example image

If you click on the id, you can see the historic data of the evaluation. The matched rules are highlighted and the input and output values are listed in the table below.

Example image

Verify that the 5th rule was matched and the output value for the desired dish is "Stew".

Next Steps

Congratulations, you have now successfully set up a project with your first DMN decision table.

Next,