cancel
Showing results for 
Search instead for 
Did you mean: 

BusinessProcessEvent and variables

mandas
Champ in-the-making
Champ in-the-making
Hi,

Is there any limitation in attaching DelegateExecution in BusinessProcessEvent in order for observers to be able to query/update process variables?

Thanks
Dimitris
5 REPLIES 5

mandas
Champ in-the-making
Champ in-the-making
Hmm if an observer catches the event after transaction completion it won't find a valid DelegateExecution right?

mandas
Champ in-the-making
Champ in-the-making
Well, my assumption was wrong. Let me explain you the use case, because this thread doesn't actually make any sense only a few hours after I 've started it Smiley Happy

I want to get task id in a CDI observer through BusinessProcessEvent. My initial thought is that I couldn't, so I 've written some code to fire my own event carrying a DelegateTask to find task id, and some variables. I still believe that my custom code is needed for the following reasons :

* After @StartActivity, the task is created in a List<PersistentObject>, but it will only be flushed when @StartActivity observer end its work. So, I cannot use TaskService even though I 'm inside JTA container, and TaskService has been initialized with interceptors which don't require a new transaction. Using TransactionPhase.AFTER_SUCCESS is not an option in my case.
* The only way to find my way out of this is to pass DelegateTask to my custom event class.

Am I right? If yes, is there any plan for activiti to support such case? would it be useful if I would create a pull request with my custom addition to be included?

Regards,
Dimitris

trademak
Star Contributor
Star Contributor
That's right. The task is only flushed to the database when a wait state is encountered or the process was ended. So before that you can't query on a newly created task and you have to work with the DelegateTask.
If your pull request contains code to make it easier to get hold of a DelegateTask then that would certainly be helpful.

Best regards,

mandas
Champ in-the-making
Champ in-the-making
Well there are two choices for implementing this :

* Using neither CdiBusinessProcessEvent, nor BusinessProcessEvent : That is, to create another class for representing task events. It's more clear in terms of code, but it will be probably confusing to observe another hierarchy of process events.
* The other solution requires to pass (and store) a VariableScope to CdiBusinessProcessEvent : However, as getting execution and process instance id is not feasible through VariableScope, I may have to modify VariableScope, ExecutionEntity and TaskEntity to use a visitor pattern to provide its own execution and process instance id.

Using #1 is more isolated, however although #2 seems nice, it will introduce execution terms in variable which I don't know if it's desired.

Any suggestions?

Regards,
Dimitris

mandas
Champ in-the-making
Champ in-the-making
Created a pull request for all these at https://github.com/Activiti/Activiti/pull/133