BPMN to DMN with business rules

I am building on the tutorials taken from the Camunda website. I have completed the bpmn process tutorial with spring boot and also the dmn one.

Im looking to combine a bpmn with dmn. Have managed to get as far as decision table being triggered but when I pass the decusion table output into to DishReviewDelete process (last step in bpmn) im unsure how to access the decision dish variable. To word this another way. How do i get the decision output in JavaDelegate tasks?

I have the following BPMN There are 4 parts to it.
The review tasks are just points where I can log output or point debugger.

  1. Season → sets Season variable … .e.g Winter
  2. SeasonReview → view variables … i.e. sanity check that Season has been set. This works ok. logs and debugger have verified this
@Component
public class SeasonReviewDelegate implements JavaDelegate {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    public void execute(DelegateExecution execution) throws Exception {
        String season = (String) execution.getVariable("season");
        logger.info("season value is", season);
    }
}
  1. Decision table Same as - “simple decision table” found here What is DMN? DMN Tutorial and Examples | Camunda

  2. Now this is the part im having trouble with. How do I get the output of the decision here?

@Component
public class DishReviewDelegate implements JavaDelegate {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    public void execute(DelegateExecution execution) throws Exception {
        logger.info("reviewing output of dish decision");
        logger.info("available keys:{}", execution.getVariables().keySet()); // only season is available here
        String dish = (String) execution.getVariable("dish");
        logger.info("dish is {} ", dish);  // this is null
    }
}

Output logs

2018-09-23 16:31:48.199  INFO 18604 --- [           main] org.camunda.bpm.container                : ENGINE-08023 Deployment summary for process archive 'appCamundaDemo': 

        simple-dish.dmn
        process-to-season-dmn.bpmn

2018-09-23 16:31:48.396  INFO 18604 --- [           main] org.camunda.bpm.application              : ENGINE-07021 ProcessApplication 'appCamundaDemo' registered for DB deployments [c915aeb0-bf45-11e8-b589-024293c421b1]. Will execute process definitions 

        DishGenerator[version: 1, id: DishGenerator:1:c9236a53-bf45-11e8-b589-024293c421b1]
Deployment does not provide any case definitions.
2018-09-23 16:31:48.421  INFO 18604 --- [           main] demo.camunda.task.SeasonDelegate         : executed set season Winter
2018-09-23 16:31:48.421  INFO 18604 --- [           main] demo.camunda.task.SeasonReviewDelegate   : season value is Winter 
2018-09-23 16:31:48.448  INFO 18604 --- [           main] demo.camunda.task.DishReviewDelegate     : reviewing output of dish decision
2018-09-23 16:31:48.448  INFO 18604 --- [           main] demo.camunda.task.DishReviewDelegate     : available keys:[season]
2018-09-23 16:31:48.448  INFO 18604 --- [           main] demo.camunda.task.DishReviewDelegate     : dish is null 

ive added demo to github here also

GitHub - davidsonr/demo-camuda: simple camunda demo with bpmn and dmn

You need to add a results variable to the business rules task that calls the DMN table.
That results variable will be available in the context of your process instance.

Not sure what you mean by setting the results variable? How do i set that?

I have tried setting the two variables below in SeasonReviewDelegate which happens just before the dmn is called, and it does not work.

execution.setVariable("results", "");
execution.setVariable("dish", "");

I mean the result variable as part of the properties panel:

and then do you get the result by the same getVariable method in the delegate class?

Yup, if you put “result” in the “Result Variable” field then you can ask for that variable using
execution.getVariable("result");

1 Like

its all working now. thanks for your help

1 Like