We’ve implmented a custom history event handler. We wish to filter the events being emitted and ideally would use the DecisionService to do that. Is it possible to access the DecisionService from within a HistoryEventHandler? It seems like it is not.
I considered using the runtimeService to start a processInstance, passing in history variables and having that processInstance run a Business Rule Task. Read the result variables from that instance in the HistoryEventHandler and then terminate the processInstance. That seems a little roundabout but it might work.
Hi,
an alternate approach you could consider is use an embedded DMN engine in your History Event Handler. This has the benefit that it doesn create yet more history events etc…
The code is quite simple - create some static instances or initialise…:
//
// Initialise a DMN engine
//
static final DmnEngine dmnEngine = DmnEngineConfiguration.createDefaultDmnEngineConfiguration().buildEngine();
//
// Load and parse the DRG model
//
static final DmnDecisionRequirementsGraph drg = dmnEngine.parseDecisionRequirementsGraph(MyHistoryHandler.class.getResourceAsStream(“/Determine_History_Filter.dmn”));
static final DmnDecision decision = drg.getDecision(“History_Filter”);
Then at runtime, use the decision in a method in your history handler…
HashMap<String, Object> variables = new HashMap();
variables.put(...);
//
// call the decision engine with the variables...
//
DmnDecisionTableResult results = dmnEngine.evaluateDecisionTable(decision, variables);
results.getSingleResult().getSingleEntry()...;
Thus you cold use a DMN engine embedded in your custom history handler…
regards
Rob
1 Like
Thank you, Rob! That’s exactly the type of solution I was hoping for, but was not aware this type of approach was possible. Off we go!