Francesco,
I'm currently using a ProcessEventListener to insert the process in the working memory just before it starts and remove it after completed. In this way I can handle processes in the working memory in a generic way. But a made your suggestion and it works, what happens is that the process needs to be updated in the working memory after I change a process variable. Now my listener looks like this and seems to be working fine.
@Override
public void afterVariableChanged(ProcessVariableChangedEvent event) {
LOGGER.debug("{}", event);
LOGGER.debug("Updating ProcessInstance on working memory");
FactHandle handle = event.getKnowledgeRuntime().getFactHandle( event.getProcessInstance() );
if(handle != null){
event.getKnowledgeRuntime().update( handle, event.getProcessInstance() );
}
}
Many thanks!