Who cares about Types? Querying with Numeric Variable Values

The final camunda 7.2 release is a stone’s throw away and ships a ton of new features. One of these is the typed variable value API. You may already know the plain-value-based API that exists since the process engine’s very first days. A variable can be set on an execution/task/… as follows:

execution.setVariable("var", 42);

Behind the scenes, the process engine performs some magic to squeeze numbers, booleans, or even complex Java objects into the database and return it from there on the next call:

int myLuckyNumber = (Integer) execution.getVariable("var");

With 7.2 (and the latest alpha), we introduce the typed value API. It is not a whole new API but rather of a gentle extension. Like before, the variable API is map-based and no existing code breaks. With the typed value API, performing the same task as above, it is possible to write

execution.setVariable("var", Variables.integerValue(42));


TypedValue typedValue = execution.getValueTyped("var");

You might have noticed the TypedValue which is the very core of this concept. Instead of the plain variable value, there is an intermediate object, the typed value.

What can you do with it? Assume there is a variable called “var” in four different process instances:

runtimeService.setVariable(processInstance1.getId(), "var", 42000);
runtimeService.setVariable(processInstance2.getId(), "var", (short) 42);
runtimeService.setVariable(processInstance3.getId(), "var", (long) 123123123);
runtimeService.setVariable(processInstance4.getId(), "var", 745.0d);

The four variables all differ in type and exact value. Yet, all are numeric values. In order to find all process instances with variable value > 10, the following can be written:

  .variableValueGreaterThan("var", 10).list();

Unfortunately, this returns only one process instance, processInstance1. Why? Because 42 is an integer value and the query only searches for process instances with an integer value greater than 10.

Often, this is not what users want. All values are numeric and can be compared on a conceptual level. That is where typed values come to the rescue. Now, it is possible to write the following process instance query:

  .variableValueGreaterThan("var", Variables.numberValue(10)).list();

This query returns all four process instances. The process engine detects that the types integer, short, long, and double are all subordinates of the type number. It now knows that you do not mean integers with value greater than 10 but any number value that is greater than 10.

Why should you care? Sometimes you don’t know the type a variable in question has. In Cockpit, users specify a numeric value to query with. Its exact type is of little interest. While some MyBatis and SQL hacks made this possible in Cockpit before 7.2, it is now a well-defined API feature. And the best: You can use it in your own queries, wherever variable values can be specified.

That is not all to it; the typed value API has much more to offer. To learn more about it, stay tuned for the release webinar, blog posts, tutorials, and examples to follow. Of course, you can right now have a look at the documentation and discover the typed value API.

  • 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?