How to implement a custom incident handler?

Hi,

we’re trying to implement a custom incident handler that will send out incident notifications using our own queuing infrastructure. We’ve written a handler class that implements both the IncidentHandler and the ProcessEnginePlugin interfaces and successfully hooked it up to the running process engine using an entry in the bpm-platform.xml file. We see that the plugin lifecycle methods are called and our incident handler is successfully installed (using setCustomIncidentHandlers). We also see that our handler is invoked through the handleIncident method once, but at that point, our engine basically stops execution and nothing else shows up in the log file.

I’m now looking for a trivial example of a custom incident handler that I could compare our implementation against. Does anyone have such an example? Can we just call setCustomIncidentHandlers in the preInit method of our plugin with just our own handler in a list, or do we need to put additional handlers into the list to maintain the standard functionality of the engine?

Any help would be greatly appreciated.

Thanks,
Hans

Code:

(ns bpm-extensions.incident-handler
  (:gen-class
   :implements [org.camunda.bpm.engine.impl.incident.IncidentHandler
                org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin])
  (:require [lambdawerk.utils :as utils]))

;; ProcessEnginePlugin interface

(defn -preInit [this process-engine-configuration]
  (utils/say "preInit called")
  (.setCustomIncidentHandlers process-engine-configuration [this])
  (utils/say "custom incident handler installed"))

(defn -postProcessEngineBuild [this process-engine]
  (utils/say "postProcessEngineBuild called"))

(defn -postInit [this process-engine-configuration]
  (utils/say "postInit called"))

;; IncidentHandler interface

(defn -getIncidentHandlerType [this]
  "failedExternalTask")

(defn -handleIncident [this process-definition-id activity-id execution-id configuration message]
  (utils/say "handleIncident called"))

(defn -resolveIncident [this process-definition-id activity-id execution-id configuration]
  (utils/say "resolveIncident called"))

(defn -deleteIncident [this process-definition-id activity-id execution-id configuration]
  (utils/say "deleteIncident called"))

Oops, I think I’ve misinterpreted the output in our log file. Everything seems to work just fine with the code that I’ve pasted.

I’m now looking for the best way to get at the properties that are defined for the plugin…

Hi Hans,

You want to use the properties from the plugin into your custom incident handler?

Cheers,
Christian

Just add String setters for the properties to your plugin. On deployment, the BPM platform invokes those via reflection.

Cheers,
Thorben

Hi Christian,

thank’s for the advice! I was suspecting that I was missing something quite obvious to a Java programmer, which I’m clearly not :slight_smile:

Best,
Hans

Could you please let me know how to implement Custom incident handler using ProcessEnginePlugin.
And to edit bpm-platform.xml file
Please give some example configuration.

Thanks,
Shankar