tjmac
July 31, 2019, 5:49pm
1
I have configured a FlowableEventListener. The issue I am seeing is that the getProcessVariables always returns 0.
I start the process with variables, I can see them in database
I complete human task and process ends.
My expectations are that the process variables would be avaliabe in following code, but logs show otherwise:
2019-07-31 12:42:41.696 INFO [gpa-workflow-service,6f6378718b3cb6fc,6f6378718b3cb6fc,false] 20621 — [ XNIO-1 task-4] .m.g.w.e.l.ProcessCompletedEventListener : Process Completed Listener : 0
Listener Stub:
@Slf4j
@Service
class ProcessCompletedEventListener implements FlowableEventListener {
@Override
void onEvent(FlowableEvent event) {
FlowableEntityEventImpl flowableEntityEvent = (FlowableEntityEventImpl) event
ProcessInstance processInstance = (ProcessInstance) flowableEntityEvent.entity
log.info("Process Completed Listener : ${processInstance.getProcessVariables().size()}")
}
@Override
boolean isFailOnException() {
return false
}
@Override
boolean isFireOnTransactionLifecycleEvent() {
return false
}
@Override
String getOnTransaction() {
return null
}
}indent preformatted text by 4 spaces
tjmac
July 31, 2019, 6:05pm
2
Here is my config the binds the listeners:
@Component
class FlowableConfigurationConfigurer implements
EngineConfigurationConfigurer<SpringProcessEngineConfiguration> {
@Autowired
@Lazy
TaskCreatedEventListener taskCreatedEventListener
@Autowired
@Lazy
TaskCompletedEventListener taskCompletedEventListener
@Autowired
@Lazy
ProcessCompletedEventListener processCompletedEventListener
@Override
void configure(SpringProcessEngineConfiguration engineConfiguration) {
//IDM Service
engineConfiguration.setIdmEngineConfigurator(new CustomIdentityConfigurator())
//Engine Event Listeners
engineConfiguration.typedEventListeners = addEngineEventListeners()
}
private LinkedHashMap<String, List<FlowableEventListener>> addEngineEventListeners() {
Map<String, List<FlowableEventListener>> typedEventListeners = [:]
typedEventListeners.put(FlowableEngineEventType.TASK_CREATED.toString(), [taskCreatedEventListener])
typedEventListeners.put(FlowableEngineEventType.TASK_COMPLETED.toString(), [taskCompletedEventListener])
typedEventListeners.put(FlowableEngineEventType.PROCESS_COMPLETED.toString(),
[processCompletedEventListener])
typedEventListeners
}
}
tjmac
July 31, 2019, 6:06pm
3
Also should note that the TASK_COMPLETED listener has the variables.
joram
August 7, 2019, 9:19am
4
getProcessVariables() only works when doing a query, see the javadoc on it:
/**
* Returns the process variables if requested in the process instance query
*/
To get the variables you can cast it to a DelegateExecution and do .getVariables()