Expressions

The pipelite-expression module provides a textual expression evaluation engine used by filter and ExpressionCondition.

Syntax

Expressions are Java strings evaluated at runtime. The central placeholder is ${body}, which refers to the current payload of the Exchange.

Available placeholders

Placeholder Resolves to

${body}

The input payload of the Exchange (equivalent to exchange.getInputPayload())

${header.<name>}

The value of the header with the specified name

Expression examples

// Filter: continue only if body is not null
${body} != null

// Filter on non-empty string
${body} != null && !${body}.isEmpty()

// Conditional routing on header
${header.type} == 'ORDER'

// Numeric comparison
${header.priority} > 5

Usage in DSL

In filter

.filter("only-valid", "${body} != null && !${body}.isEmpty()")

The ExpressionFilterNode evaluates the expression on each Exchange. If the evaluation returns false, message processing stops.

In ExpressionCondition

.toRoute(route -> route.contentBased()
    .when(new ExpressionCondition("${header.type} == 'PAYMENT'"), "link://payment-flow")
    .otherwise("link://default-flow")
    .build()
)

Implementation

The expression engine is implemented in TextExpressionEvaluator (module pipelite-core). It resolves placeholders on the ExpressionVariables populated from the current Exchange.

The ExpressionUtils (package io.pipelite.core.support.expression) provides helper methods for programmatic expression evaluation.

The expression engine is intentionally simple. For complex conditional logic, prefer using a Processor with standard Java code.