How Do I Call Java Method Asynchronously in Activity Execution Listener?

I have an execution listener that invokes a Java method from a custom class I have developed. I want this listener and any invoked methods, etc. to run asynchronous. In other words, when the process hits and event (e.g. start), I want this to be invoked asynchronously so that the method and associated processes/threads run without causing the process (workflow) to wait for their completion.

I’m not particularly concerned about managing this asynchronous execution or managing any exceptions it might throw. I just don’t want it slowing my processes down while it does its work.

Here are the relevant parts of my listener:

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.ExecutionListener;
import com.company.app.SendProcessHistory;

public class SendProcessHistoryActivityListener implements ExecutionListener {

	@SuppressWarnings("static-access")
	public void notify(DelegateExecution execution) throws Exception {

		SendProcessHistory newHistoryRecord = new SendProcessHistory();

		newHistoryRecord.recordProcessHistory(execution, execution.getCurrentActivityId() + ":" + execution.getEventName());

	}

}

Thank you.

Hi @mppfor_manu,

the process engine doesn’t offer any service for this. However, it’s a general Java question and you can find many tutorials regarding concurrency - for example this.

Best regards,
Philipp