Red Hat Bugzilla – Bug 826578
Work item handler is lost after session reloading
Last modified: 2012-07-03 18:57:18 EDT
Description of problem:
This problem was revealed with adhoc subprocess, but I think it is more general. For example when the session is reloaded during task execution, after its completing the next task in the flow ends with the exception.
In this case, when the adhoc process is started, it waits for signalling each process fragment (or single task). If the knowledge session is reloaded from DB and the task (which needs work item handler) is signalled, org.drools.WorkItemHandlerNotFoundException is thrown.
Please, take a look at org.jbpm.bpmn2.SimpleBPMNProcessTest.testAdHocProcessDynamicTask(). First, persistence needs to be enabled in the SimpleBPMNProcessTest.
org.drools.WorkItemHandlerNotFoundException when the task is triggered after the session reloading. I don't think this is user friendly behavior.
Work item handler should be reloaded with the session.
This behavior is as designed.
Work item handlers act as a connection between the engine and some external service. Whenever a session is disposed and restored later from database, these handlers typically need to be reinitialized (for example, imagine the system went down completely, in that case the handler needs to relocate and reconnect to the external services). These handlers typically also reference other systems, so they can't just be serialized. Handlers also shouldn't be maintaining any state themselves, so not sure why they need to be persisted.
Work item handler registration is a normal part of session initialization, so whenever a session needs to be restored, registering the necessary handlers could be considered as part of the normal session initialization.
If the user would like to avoid having to manually register handlers whenever a session is created, a configuration file can be used to load service handlers from that.
thanks for the clarification, you are right - but I still wonder if it would be possible to provide some helper class / method which copies registered listeners and work item handlers from the given session to the newly loaded session. And when user provides no session to copy from, well - it's his job. This copying might save a lot of lines of code.