Source:
public ServiceResponse<DMNResultKS> evaluateDecisions(String containerId, String contextPayload, String marshallingType) { try { KieContainerInstanceImpl kContainer = context.getContainer(containerId, ContainerLocatorProvider.get().getLocator()); KieSession kieSession = kContainer.getKieContainer().newKieSession(); DMNRuntime dmnRuntime = kieSession.getKieRuntime(DMNRuntime.class); PrometheusKieServerExtension extension = (PrometheusKieServerExtension)context.getServerExtension(PrometheusKieServerExtension.EXTENSION_NAME); if (extension != null) { List<DMNRuntimeEventListener> listeners = extension.getDMNRuntimeListeners(kContainer); boolean listenersAlreadyAdded = dmnRuntime.getListeners().containsAll(listeners); if (!listenersAlreadyAdded) { listeners.forEach(l -> dmnRuntime.addListener(l)); } } LOG.debug("Will deserialize payload: {}", contextPayload); DMNContextKS evalCtx = marshallerHelper.unmarshal(containerId, contextPayload, marshallingType, DMNContextKS.class); DMNEvaluationResult evaluationResult = DMNEvaluationUtils.evaluate(dmnRuntime, evalCtx.getNamespace(), evalCtx.getModelName(), evalCtx.getDmnContext(), evalCtx.getDecisionNames(), evalCtx.getDecisionIds(), evalCtx.getDecisionServiceName()); DMNResultKS res = new DMNResultKS(evaluationResult.model.getNamespace(), evaluationResult.model.getName(), evalCtx.getDecisionNames(), evaluationResult.result); kieSession.dispose(); return new ServiceResponse<DMNResultKS>( ServiceResponse.ResponseType.SUCCESS, "OK from container '" + containerId + "'", res ); } catch ( Exception e ) { e.printStackTrace(); LOG.error( "Error from container '" + containerId + "'", e ); return new ServiceResponse<DMNResultKS>( ServiceResponse.ResponseType.FAILURE, "Error from container '" + containerId + "'" + e.getMessage(), null ); } }

Target:
public ServiceResponse<DMNResultKS> evaluateDecisions(String containerId, String contextPayload, String marshallingType) { try { KieContainerInstanceImpl kContainer = context.getContainer(containerId, ContainerLocatorProvider.get().getLocator()); KieSession kieSession = kContainer.getKieContainer().newKieSession(); DMNRuntime dmnRuntime = kieSession.getKieRuntime(DMNRuntime.class); PrometheusKieServerExtension extension = (PrometheusKieServerExtension)context.getServerExtension(PrometheusKieServerExtension.EXTENSION_NAME); if (extension != null) { PrometheusMetricsDMNListener listener = new PrometheusMetricsDMNListener(PrometheusKieServerExtension.getMetrics(), kContainer); dmnRuntime.addListener(listener); List<DMNRuntimeEventListener> listeners = extension.getDMNRuntimeListeners(kContainer); listeners.forEach(l -> { if (!dmnRuntime.getListeners().contains(l)) { dmnRuntime.addListener(l); } }); } LOG.debug("Will deserialize payload: {}", contextPayload); DMNContextKS evalCtx = marshallerHelper.unmarshal(containerId, contextPayload, marshallingType, DMNContextKS.class); DMNEvaluationResult evaluationResult = DMNEvaluationUtils.evaluate(dmnRuntime, evalCtx.getNamespace(), evalCtx.getModelName(), evalCtx.getDmnContext(), evalCtx.getDecisionNames(), evalCtx.getDecisionIds(), evalCtx.getDecisionServiceName()); DMNResultKS res = new DMNResultKS(evaluationResult.model.getNamespace(), evaluationResult.model.getName(), evalCtx.getDecisionNames(), evaluationResult.result); kieSession.dispose(); return new ServiceResponse<DMNResultKS>( ServiceResponse.ResponseType.SUCCESS, "OK from container '" + containerId + "'", res ); } catch ( Exception e ) { e.printStackTrace(); LOG.error( "Error from container '" + containerId + "'", e ); return new ServiceResponse<DMNResultKS>( ServiceResponse.ResponseType.FAILURE, "Error from container '" + containerId + "'" + e.getMessage(), null ); } }