Camunda BPM 7.1.0-alpha4 features a new fluent API for message correlation.

BPMN 2.0 defines events and tasks catching messages. The following is a fragment of a process waiting for an order to be cancelled:

Intermediate Message Catch Event
Intermediate Message Catch Event

In BPMN 2.0 XML you have to provide a name for the message you want to catch:

<bpmn2:definitions ...>
  ...
  <bpmn2:message id="<b>Message_1</b>" name="<b>orderCancelled</b>"/>
  ...
  <bpmn2:process id="Process_1" isExecutable="false">
    ...
    <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_2" name="Order 
Cancelled">       
      <bpmn2:messageEventDefinition messageRef="<b>Message_1</b>"/>
    </bpmn2:intermediateCatchEvent>
    
  </bpmn2:process>

New Fluent API

Camunda Engine now features a fluent DSL for correlating this message to the process engine:

  runtimeService.createMessageCorrelation("<b>orderCancelled</b>")
      .processInstanceBusinessKey("someOrderId")
      .setVariable("CANCEL_REASON", "someReason")
      .setVariable("CANCEL_TIMESTAMP", new Date())
      .correlate();

The fluent DSL makes it easy to define a complex correlation set based on different restrictions. The above example correlates the message on the business key. On top of that, correlation based on process variables and process instance id is supported:

runtimeService.createMessageCorrelation("<b>orderCancelled</b>")
      .processInstanceVariableEquals("orderId", "someOrderId")
      .processInstanceVariableEquals("customerId", "someCustomerId")
     .correlate();


  runtimeService.createMessageCorrelation("<b>orderCancelled</b>")
      .processInstanceId("someProcessInstanceId")
      .correlate();

The API also makes it easy to provide the message payload as a single or multiple variables through setVariable(varName, value).

More Efficient than Query + Trigger

We recommend using the fluent DSL or the RuntimeService.correlateMessage(…) methods introduced in 7.0 over the Query + Trigger pattern. Using the Query + Trigger pattern you first query for an execution having a message event subscription and then trigger that execution:

Not as efficient:

  // Query
  Execution e = runtimeService.createExecutionQuery()
    .processInstanceBusinessKey("someOrderId")
    .messageEventSubscriptionName("<b>orderCancelled</b>")
    .singleResult();
  Map<String, Object> variables = new HashMap<String, Object>();
  variables.put("CANCEL_REASON", "someReason");
  variables.put("CANCEL_TIMESTAMP", new Date());


  // Trigger
  runtimeService.messageEventReceived("<b>orderCancelled"</b>, e.getId(), variables);

The Query + Trigger pattern has two disadvantages:

  1. More lines of code 🙂
  2. Two process engine commands instead of a single one. This makes it less efficient in terms of performance.
  • Monitoring Camunda Platform 7 with Prometheus

    Monitoring is an essential facet of running applications in a production system. Through this process, organizations collect and analyze data, and determine if a program is performing as expected within set boundaries. When combined with alerting, monitoring allows for detecting unexpected system behavior to mitigate exceptional situations as fast as possible. Furthermore, tracking the performance of a system enables organizations to improve those aspects that have the biggest impact with higher priority. One essential aspect of monitoring is the list of key metrics you want to observe. There are different categories of statistics that can be of interest here. To observe the defined metrics, there are plenty of application monitoring tools on the market today. They differ in many aspects...

    Read more
  • Securing Camunda 8 self-managed cluster and applications...

    Directory services are an effective way to manage an organization’s users, groups, printers, devices, and more. Most organizations accomplish this using Active Directory, Apache Directory, Oracle Internet Directory, or other similar tools. Recently I worked with a customer who wanted to see how he could secure the Camunda 8 Platform and process applications with such a directory. Their requirements consisted of: Allowing Directory users to access Camunda applications (Tasklist, Operate, Optimize) Accessing secured Tasklist & Operate APIs from our custom project Securing the custom project In this article, I’ll briefly explain the 3 easy steps taken to fulfill their requirements which include: Federate users from the Directory service into Keycloak Declare an application in Identity to access Camunda APIs Configure...

    Read more
  • Accelerate Connectivity with Camunda Platform 8.1

    We’re thrilled to announce Camunda Platform 8.1, the latest release of our process orchestration solution. This new version introduces features that accelerate connectivity to the many different systems and technologies that are required for true digital transformation, including: Create custom Connectors with our Integration Framework to accelerate connectivity New out-of-the-box Connectors for popular services Enhancements to Camunda Modeler that improve productivity Hot backups and official support for Amazon EKS and Red Hat OpenShift Plus, several upgrades requested by Camunda Platform 7 customers Organizations across all industries rely on complex technology stacks to adapt and enhance their operations in response to market dynamics, new disruptive companies, and increasing consumer expectations. Your technology stack likely includes everything from cutting-edge technologies to legacy...

    Read more

Ready to get started?

Still have questions?