cancel
Showing results for 
Search instead for 
Did you mean: 

Options for Lifecycle Event Listeners / Interceptors

jjfutt
Champ in-the-making
Champ in-the-making
Hello:

This is a continuation of my questions from a previous thread (now closed http://forums.activiti.org/en/viewtopic.php?f=6&t=3691) regarding the options for implementing Lifecycle Event listeners.

Our Objective: Implement Java listeners that can do 'stuff' when events such as Process started, completed, execution taken etc occur. Ideally, we want to do this without having to code the listeners in the process (something similar to to Aspect Oriented Programming, where we could configure events and observers external to the process definition).

Our Execution Environment: We'll be running the Activiti engine in NON-JAVAEE containers (Tomcat, standalone JVMs, Mule)

Our Process Engine Configuration: We' have had success with both StandaloneProcessEngineConfiguration and SpringProcessEngineConfiguration

Based on the information provided in the user guide and the ActivitiInAction book, I have narrowed down the following options for implementing event listeners. I'd appreciate if somebody could verify /and/or answer the questions below:

  • Option 1: Implement Task Listeners within the Process Definition itself (doable of course, but not desired in our case because it requires explicit coding)

  • Option 2: Use the 'Activiti-CDI' module – either in a JEE container that provides CDI (JSR299/JSR330?) implementation, or use a CDI implementation such as 'WELD' for deployment in a non-JavaEE container. In these configurations, the user guide describes the use of @Observer annotation to listen to lifecycle events.
Questions:
  • Q1: Are the above mentioned methods the only two options for listening to Lifecycle events? Is there any other interceptor/events mechanism that can be leveraged? Is there a way to leverage Spring AOP on process lifecycle events?

  • Q2: Is WELD the only option to to use in non-Java-EE enviornments? If we are using SpringProcessEngineConfiguration, does it open any doors to any spring oriented options?
Thanks in advance.
3 REPLIES 3

tiesebarrell
Champ in-the-making
Champ in-the-making
well, there's also a totally different way you could do this which would be to write your own ExportMarshaller for Activiti Designer (if you're using that to model the process) which actually outputs the listeners straight into the BPMN automatically. That way, you don't have to do it by modelling it by hand. If you need fixed stuff for each and every process, this should be quite straightforward, otherwise you might have to implement some logic to do customized stuff for each process, which you can do if the information you need is in the process somehow.

jjfutt
Champ in-the-making
Champ in-the-making
tiesebarrell: Thank you very much for your response. I guess we'll look at a 'post processor something along the lines of ExportMarshaller for adding these listeners.

damokles
Champ in-the-making
Champ in-the-making
Another way to add your listeners to the process is by using the org.activiti.engine.impl.bpmn.parser.BpmnParseListener
take a look at the org.activiti.engine.impl.history.handler.HistoryParseListener for an example. This is more like the AOP
approach since you just have to add your custom listener to the activiti config (e.g., activiti.cfg.xml) and you can add
your listeners to the process when it is loaded.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.