Custom eMail Task integration


we are currently integrating Flowable into our existing infrastructure, but there is one point I cannot figure out:

We need to use our custom eMail sending framework for sending outgoing mail (using the Mail Task) and cannot use the built-in mail sending code. Is there any way to configure the whole Process Engine to use our mail sending code? I read something about MailActivityBehaviour but I could not figure out how to configure some custom logic here…

Thanks in advance,

Hi Mike,
have you tried to extend the DefaultActivityBehaviorFactory and overwrite the method protected MailActivityBehavior createMailActivityBehavior(String taskId, List<FieldExtension> fields)? There you should be able to instantiate your own implementation of the MailActivityBehavior? Afterward, you should be able to set the ActivityBehaviorFactory during the creation of your ProcessEngineConfiguration, see therefore

Kind regards,

Hey Mike,

What Valentin suggested will help you create your own implementation.

I on the other side are interested to know why using the current implementation is not sufficient. Is there something that is missing? We can of course extend and add more functionality to the Mail Task so you can use it as is. Is it possible for you to share this information?



I tried Valentins solution and it was exactly what I needed, thank you!

Filip, I dont think anything is missing from the Mail task but we have a setup where we have to use a database based mail queue for documentation reasons. Also some messages are not sent using email but using messaging services - this is transparent to the business process logic.


Sory for refreshing topic.
@mtraunau have you implemented your own ActivityBehaviourFactory? Can you share how it is done?

@valentin Is there any example how to override ActivityBehaviourFactory? I tried to setActivityBehaviour in ProcessEngineConfiguration but it makes whole configuration manual which I want to avoid (database, transaction etc.) or I do something wrong.

Hi @dcwik96,

in case you are using Spring, have you tried to use a EngineConfigurationConfigurer?


1 Like


in fact i did implement an ActivityBehaviourFactory. It looks like this:

public class DataReporterActivityBehaviorFactory extends DefaultActivityBehaviorFactory {

  public MailActivityBehavior createMailActivityBehavior(ServiceTask serviceTask) {
    return createMailActivityBehavior(serviceTask.getId(), serviceTask.getFieldExtensions());

  public MailActivityBehavior createMailActivityBehavior(SendTask sendTask) {
    return createMailActivityBehavior(sendTask.getId(), sendTask.getFieldExtensions());

  protected MailActivityBehavior createMailActivityBehavior(String taskId, List<FieldExtension> fields) {
    List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(fields);
    return (MailActivityBehavior) ClassDelegate.defaultInstantiateDelegate(DataReporterMailActivityBehavior.class, fieldDeclarations);


The ActivityBehaviour itself looks like this:

public class DataReporterMailActivityBehavior extends MailActivityBehavior {

  public void execute(DelegateExecution execution) {




Configuration for the whole engine is done here:

try {
	// Create Flowable engine
	ProcessEngineConfiguration pec = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();


	ArrayList<FlowableEventListener> eventListeners = new ArrayList<FlowableEventListener>();
	eventListeners.add(new DefaultEventLogging());

	((ProcessEngineConfigurationImpl) pec).addConfigurator(new FormEngineConfigurator());
	((ProcessEngineConfigurationImpl) pec).setActivityBehaviorFactory(new DataReporterActivityBehaviorFactory());


	pec.buildProcessEngine();"Flowable Business Process engine startup ready");

} catch (Exception e) {
	log.log(Level.SEVERE, "Flowable Initialization error", e);
	return false;

I hope this helps - I wrote this code some months ago so I can’t recall the exact details…

Best regards

1 Like