bpmn 2.0 xml
<?xml version="1.0" encoding="UTF-8"?><definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:flowable="http://flowable.org/bpmn" id="sid-a99401d1-6896-44b4-ace0-6898edf8e711" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://www.omg.org/spec/BPMN/2.0/20100501/BPMN20.xsd" targetNamespace="http://flowable.org/bpmn20">
<process id="testEventListener" name="testEventListener" isExecutable="true">
<extensionElements>
<flowable:eventListener delegateExpression="${growEventListener}" entityType="task" />
</extensionElements>
...
</process>
</definitions>
bean:
package de.rrze.flowable.listener
import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType
import org.flowable.common.engine.api.delegate.event.FlowableEvent
import org.flowable.common.engine.api.delegate.event.FlowableEventListener
import org.slf4j.LoggerFactory
import org.flowable.common.engine.impl.cfg.TransactionState
class GrowEventListener implements FlowableEventListener {
def bpmHistoryService
protected String onTransaction
static def log = LoggerFactory.getLogger('GrowEventListener')
GrowEventListener() {
this.onTransaction = TransactionState.COMMITTED.name();
}
GrowEventListener(String onTransaction) {
this.onTransaction = onTransaction;
}
@Override
void onEvent(FlowableEvent event) {
log.info "***********************************"
log.info isFireOnTransactionLifecycleEvent()
log.info getOnTransaction()
log.info event.type
// log.info "task created"
def task = event.getEntity()
log.info task.processInstanceId
def processActivities = bpmHistoryService.findActivitiesForProcInst(task.processInstanceId)
def activities = []
processActivities.each{activity->
activities << [name: activity.activityName, type: activity.activityType, assignee: activity.assignee , startTime: activity.startTime,endTime: activity.endTime, duration: activity.durationInMillis]
}
log.info "${activities}"
}
@Override
boolean isFailOnException() {
return false
}
@Override
boolean isFireOnTransactionLifecycleEvent() {
return true
}
@Override
String getOnTransaction() {
return onTransaction
}
}
in eventListener onEvent method i want to get all history activities especially included just created user task when a user task was created (on transaction : committed) but it seems that onEvent is executed before transaction committed. because i can only get all history activities before this created user task. is there something still need to be set in bpmn20.xml? p.s. with using TransactionDependentTaskListener to create transactonTaskListener seems to work. why?