-
1. Re: taskInstance.cancel() still fires events
olivier_debels Apr 8, 2008 3:45 AM (in response to dleerob)We extended taskInstance with an abort(), which does the same as cancel() but doesn't fire events and doesn't signal the token.
We use this in a number of use cases. For example we have situations where user want to merge two task instance in different process instances. The use initially thought he would do the job in two separate tasks, but decides afterwards to do it in a single one. In this case we want to abort the second process instance and all task instances it contains. -
2. Re: taskInstance.cancel() still fires events
dleerob Apr 8, 2008 3:58 AM (in response to dleerob)Thanks Olivier...you always come back with useful info/ideas.
How do you get Jbpm to make use of your extended TaskInstance class, instead of using the original TaskInstance class? -
3. Re: taskInstance.cancel() still fires events
olivier_debels Apr 8, 2008 4:19 AM (in response to dleerob)Our custom task instance subclasses the jbpm task instance, we also provide a custom hibernate mapping (again extending the one of jbpm).
We created a custom TaskInstanceFactory (which creates our custom task instance) and made sure jbpm is using this one. You can set override this setting in jbpm.cfg.xml.<bean name="jbpm.task.instance.factory" class="???.task.factory.CustomTaskInstanceFactory" singleton="true" />
This is also described somewhere in the jbpm documentation. -
4. Re: taskInstance.cancel() still fires events
dleerob Apr 8, 2008 4:24 AM (in response to dleerob)Thanks for your time.
Hopefully an "abort" method will be added to JBPM in a future release. :) -
5. Re: taskInstance.cancel() still fires events
dleerob Apr 8, 2008 5:58 AM (in response to dleerob)I found quite a simple way to make sure a "task-end" event does not get fired when cancelling a task instance. I remove the event, cancel the task instance, and then add the event back.
Simply use code similair to the following:taskInstance.setSignalling(false); Task task = taskInstance.getTask(); Event endTaskEvent = task.getEvent(Event.EVENTTYPE_TASK_END); if (endTaskEvent != null) { task.removeEvent(endTaskEvent); } taskInstance.cancel(); if (endTaskEvent != null) { task.addEvent(endTaskEvent); }
It seems to work fine for me. Can anyone see anything wrong with doing it this way? It doesn't seem to update the database with new events or actions or anything, as you are adding back the same event object. -
6. Re: taskInstance.cancel() still fires events
olivier_debels Apr 8, 2008 7:02 AM (in response to dleerob)Depends what you want.
In your case task-end event will not get fired, but the task instance will end and process instance will continue (token will signal). The task-end event will never fire again (since task instance was already added), so adding it again is not needed.
If you want your process instance to continue and if you want your task instance to complete, but without events, then this is ok.
If you want your process instance to 'abort', and your task instance to 'abort' where you can make a distinction between completed task instances and aborted ones, then this is not ok. -
7. Re: taskInstance.cancel() still fires events
jdriver Apr 9, 2008 10:23 AM (in response to dleerob)Any possibility of sharing the code for CustomTaskInstanceFactory and extended TaskInstance class?
-
8. Re: taskInstance.cancel() still fires events
kukeltje Apr 9, 2008 10:42 AM (in response to dleerob)if willing to share, please put in on the wiki... would be a nice addition/example