I have found example of attaching task listener so that an email is sent when the task is created.
Is it possible to have this behaviour for all processes, without attaching the delegate specifically to a task? Also, there will be some user tasks that can be created on the tasklist, is there a way to do that?
The observer method has the parameter
BusinessProcessEvent businessProcessEvent
You could get the delegate task through
businessProcessEvent.getTask() from where you could get the assignee by calling getAssignee()
Hi … the reactor extension would be my tool of choice here as well, but I as the author, am biased … what you can do, if you want to simulate the behavior:
add a custom BpmnParseListener (either directly to the configuration or via ProcessEnginePlugin#preInit()
in that parse listener, register your “send eMail notification” code as a taskListener for task#create:
BpmnParseListener emailParseListener = new AbstractBpmnParseListener(){
@Override
public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {
TaskDefinition taskDefinition = ((UserTaskActivityBehavior) activity.getActivityBehavior())
.getTaskDefinition();
taskDefinition.addTaskListener(TaskListener.CREATE, new TaskListener(){
@Override
public void notify(DelegateTask delegateTask) {
// your email code here
}
});
}
};
processEngineConfiguration.getCustomPostBPMNParseListeners().add(emailParseListener);
`
This is our simple Servlet, which we deploy as a war on a tomcat where we installed a shared process engine. The getTaskListener method is never invoked