Overriding ReceiveTaskActivityBehavior

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Member II

Overriding ReceiveTaskActivityBehavior

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
Senior Member

Re: Overriding ReceiveTaskActivityBehavior

> 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);