External Task Listener

Hi, just a heads up, I’m a newbie in the camunda world :slight_smile:

I am trying to build a publish subscribe model for external tasks in Camunda.
I have the camunda-bpm-reactor extension to have a task listener.
It seems that in order to have the listener work I need to listen for ‘userTask’ type even though the actual type of the task in the CamundaModeler is ‘serviceTask’ with external implementation.

So the question is, am I listening to the correct task type and if so, is it possible from the ‘DelegateTask’ instance to figure out the type of the task because I am only interested in the external implementation of the ‘serviceTask’ type and the topic name?

visual example:

public void notify(DelegateTask delegateTask) {
if (delegateTask.isExternalTask()) {
//find topic name and do smth
}
}

@dimitaruserTask’ type doesn’t supports external task pattern. External task pattern is supported in task type “ServiceTask” .

If you want to write some logic in userTask type, you can implement either ExecutionListener or TaskListener .

For ServiceTask type you have to configure either Delegate or External Task Pattern. Delegates must be available in classpath. For External task pattern you need to configure topic and workers will poll the tasks of type external and will complete the task and will commit the completion/failed state to process engine.

For more details refer the external-tasks docs.

For delegation code refer this docs

It may also be worth following this video tutorial. It shows how to build an external task patter architecture with Camunda.
-Niall

Thank you for replying @aravindhrs and @Niall .

I guess I wasn’t clear enough because of my basic camunda knowledge. As @Niall suggested I went through the video tutorial and I understand the architecture (nice hawk btw :slight_smile:), but that approach uses polling or long polling.

I would like to have publish/subscribe system where Camunda notifies another system.

What I would like to achieve here is that every time a process instance of any process definition is run and is blocked because it is waiting for an external task to be completed, another third party messaging system is notified with the following information:

  • id or key of the blocked process instance
  • id of the external task that needs to be completed
  • topic name

How do I achieve this?

With the latest update from @aravindhrs it seems that I need to create a delegate just that it notifies another system which seems completely wrong as an approach.

NOTE: For my prototyping I am running my own Camunda service with spring boot starters and the reactor extension.

EDIT: With my previous question my intention was to create a global task listener in Camunda that only triggers on creation of external service tasks in order to notify the third party system.

@dimitar the above replies clearly tells you how to configure service task and how to use Java Delegates and Listeners.

If you are looking for kafka integration with process engine for publish-subscribe pattern look at this example:

You may also want to take a look at Zeebe which is an workflow engine designed for more event oriented architectures.

@aravindhrs @Niall Thank you guys, I managed to implement the Delegate. It is working as intended and I have more insight how to make the system work.