Java
Latest commit 14ebda9 Feb 6, 2017 @jangalinski jangalinski committed on GitHub add maven coordinates
Permalink
Failed to load latest commit information.
docs Rename index.md to index.html Sep 20, 2016
examples
extension introduce pair event Jan 16, 2017
.editorconfig initial setup, plugin is working Oct 8, 2015
.gitignore
.java-version
.travis.yml Switch to java8 Jan 12, 2017
CONTRIBUTING.md
LICENSE
README.adoc add maven coordinates Feb 6, 2017
pom.xml switch to java8, camunda 7.6, introduce eventBridge Jan 11, 2017

README.adoc

camunda-bpm-reactor

Event-based listeners and delegates for camunda.

Logo
License Apache%202.0 blue
badge
badge
project thin badge
camunda bpm reactor

What is this about?

This extension provides a process engine plugin that registers Execution- and TaskListeners to all possible elements and all possible events. These listeners then publish their delegates (DelegateTask, DelegateExcution) to an event bus.

Custom implementations that are interested in certain events may register on that bus and will get notified and executed when the registered listeners fire.

Publishing and subscribing uses a topic pattern /camunda/{context}/{type}/{process}/{element}/{event} so it is possible to register on all that happens on the engine or the assignement event of a concrete userTask in a concrete process.

Reference: a similar approach was already done in the engine-cdi module using CDI observers and qualifiers.

Why do I need this?

Using an event bus decouples registration and implementation of listeners. The bpmn file has not to be touched for this. This is useful for implementations that can be considered "aspects" of the engine like task assignment and monitoring.

Instead of registering listeners all over your bpmn files that always call the same rule service to determine the candidate groups of a task or write runtime information to a data source, you just hook into the event bus stream and wait for notification.

While this could be achieved with custom plugins/parselisteners, these share the problem that the engine has to have access to the code of the listeners added. With the decoupling via eventbus, this is avoided.

How is it done?

This extension uses the event bus provided by projectreactor.io. This bus is fairly advanced and stable and allows separation of event-payload (the DelegateExpression) and event topic, so we do not need any additional qualifiers or concrete types to distinct between "listen to create of task B" or "listen to all events of task A".

Using the extension is straight forward, you need to:

  • access the eventBus instance used in the plugin by calling CamundaReactor.eventBus().

  • Use this bus to register an instance of an appropriate listener and specify the topic parts you are interested in.

Examples

Register a listener that is fired for all "create" events on any user task in the system.

@CamundaSelector(type = "userTask", event = TaskListener.EVENTNAME_CREATE)
public class TaskCreateListener implements TaskListener {

  public TaskCreateListener(EventBus eventBus) {
    eventBus.register(this);
  }

  @Override
  public void notify(DelegateTask delegateTask) {
   ...
  }
}

More examples can be found in the sub-module [examples](examples).

Noteworthy

This extensions works with delegateTasks and delegateEvents directly. These cannot be used outside the current thread, so the eventBus used is synchronous.

Spring Boot

  • the reactor-spring-starter was removed with 1.5.0, in favor of introducing the new @EnableCamundaReactor annotation. Just use it on your spring boot application to activate bus and plugin.

Maven Coordinates

Latest released version on maven central

<dependency>
  <groupId>org.camunda.bpm.extension</groupId>
  <artifactId>camunda-bpm-reactor-core</artifactId>
  <version>1.2</version>
</dependency>

Latest snapshot

<dependency>
  <groupId>org.camunda.bpm.extension.reactor</groupId>
  <artifactId>camunda-bpm-reactor-core</artifactId>
  <version>1.5-SNAPSHOT</version>
</dependency>

<repository>
  <!-- you have to add the snapshot repository -->
  <id>maven-central-snapshots</id>
  <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
</repository>

Next Steps

  • provide extension for CDI (?)

  • use eventbus for message correlation end/start

  • …​

Maintainer

License

  • [Apache License, Version 2.0](./LICENSE)