cancel
Showing results for 
Search instead for 
Did you mean: 

Overriding ReceiveTaskActivityBehavior

erwincc
Champ in-the-making
Champ in-the-making

Is there a way for me to extend ReceiveTaskActivityBehavior and override its behavior? I am not sure how to create a single listener which can be used across all Receive tasks for a workflow - in the same way as a ServiceTask listener can be configured to be used as a listener for many ServiceTasks - so I am trying to see if this can be an option. 

Thanks for your answers in advance.

1 REPLY 1

daisuke-yoshimo
Star Collaborator
Star Collaborator

> I am not sure how to create a single listener which can be used across all Receive tasks for a workflow - in the same way as a ServiceTask listener can be configured to be used as a listener for many ServiceTasks - so I am trying to see if this can be an option.

You can use ActivitiEventListener.
https://www.activiti.org/userguide/#eventDispatcherListener

1. Make ActivitiEventListener that will be executed in only recive task.
I attached tha sample java code.

@Override
public void onEvent(ActivitiEvent event) {
    if( (event instanceof ActivitiActivityEvent)
      &&("receiveTask".equals( ((ActivitiActivityEvent) event).getActivityType()) )
      &&( ActivitiEventType.ACTIVITY_COMPLETED.equals( event.getType() ) )
    ){
・・・・・・・・・・・・・・・・・
     }

}

2. SetEventListeners to ProcessEngineConfiguration

ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
List<ActivitiEventListener> eventListeners = new ArrayList<ActivitiEventListener>();
eventListeners.add(new YourActivitiEventListener());
((ProcessEngineConfigurationImpl)processEngineConfiguration).setEventListeners(eventListeners);