cancel
Showing results for 
Search instead for 
Did you mean: 

Immutable process instance variables

slickrobert
Champ in-the-making
Champ in-the-making
Hi, I was wondering if there were any suggestions for ways to implement immutable process instance variables using Activiti Engine and the Activiti REST API.

I am designing a process where process instance variables are set upon creation for an initial "approval request" and these variables must not be changed by downstream tasks. To my knowledge, process instance variables can be overridden at any point in time by the REST API. I have been thinking about the best ways to enforce immutability of these variables, but I wanted to see if there were other options, and perhaps guidance for option 2.

1. Create custom endpoints for process instance creation, task approval, for this particular process definition. This would allow me to restrict or validate user input for downstream tasks.
2. Create a task listener that will check if an existing process variable has been changed, and "reject" the task from completing the task – though I am not sure how to implement this option. Can the listeners autowire beans?

Any guidance is appreciated.
2 REPLIES 2

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Option 2 is feasible. Use Event handlers and VARIABLE_UPDATED event (http://activiti.org/userguide/index.html#eventDispatcherEventTypes).
Listen to the event and throw an exception afterwards.
Regards
Martin

jbarrez
Star Contributor
Star Contributor
Option 1 is feasable too - the REST app is a regular Spring MVC app with component scanning. Put your custom endpoints in the right package and that's it.