Open Source API Gateway
2. Enterprise Integration Patterns

setProperty

Version

Sets an exchange property to a constant string or a computed value. Unlike a header or the body, a property is not sent to the client; it is only readable by later interceptors in the same exchange, e.g. as ${property.name} in a template or another expression. The value is evaluated as a SpEL template, Groovy, JsonPath, or XPath expression, defaulting to SpEL. See tutorials/orchestration/30-Orchestration.yaml.

Example Configuration

api:
port: 2000
flow:
- setProperty:
name: product
value: ${$.product_id}
language: jsonpath
- call:
url: https://api.predic8.de/shop/v2/products/${property.product}
api:
   port: 2000
   flow:
     - setProperty:
         name: product
         value: ${$.product_id}
         language: jsonpath
     - call:
         url: https://api.predic8.de/shop/v2/products/${property.product}

Syntax

setProperty:
'$ref': <string>
failOnError: <boolean>
ifAbsent: <boolean>
language: groovy
name: <string>
value: <string>
xmlConfig: {}
setProperty:
  '$ref': <string>
  failOnError: <boolean>
  ifAbsent: <boolean>
  language: groovy
  name: <string>
  value: <string>
  xmlConfig: {}

Attributes

NameRequiredDefaultDescriptionExamples
$reffalse-Reference a component defined under components.-
failOnErrorfalsetrueWhen true, aborts processing if expression evaluation fails. When false, logs the error and continues unchanged.false
ifAbsentfalsefalseWhen true, only sets the field if it is not already present in the message.true
languagefalseSpELScripting language used to evaluate the value expression.SpEL | groovy | jsonpath | xpath
namefalse-Name of the header field or exchange property key to set.X-Powered-By
valuefalse-Value to assign, evaluated as a SpEL template expression by default. Use the language attribute to switch to Groovy, JsonPath, or XPath.${method}

Child Structure

ElementCardinalityDescription
xmlConfig0..1XML namespace declarations for XPath expressions in the value.

Can be used in