Chapter 23. Extract Field Action
Extract a field from the message body.
The extract field action expects an application/json content type.
The field parameter specifies which field in the JSON to extract. By default, the message body is overridden with the extracted field.
The optional parameter headerOutput specifies whether the extracted field should be stored in a message header named 'CamelKameletsExtractFieldName', leaving the message body untouched.
The optional parameter headerOutputName specifies a custom header name instead of the default 'CamelKameletsExtractFieldName'. This parameter must be used in conjunction with headerOutput. If no headerOutputName parameter is provided, the default 'CamelKameletsExtractFieldName' is used.
The optional parameter strictHeaderCheck enables a strict header name check. If enabled, the action checks if the header output name (custom or default) is already used in the exchange. If so, the extracted field is stored in the message body, if not, the extracted field is stored in the selected header (custom or default).
The headerOutput/headerOutputName/strictHeaderCheck parameters are particulary useful in case you would like to reuse an extracted field as parameter for another header, for example.
23.1. Configuration Options Copy linkLink copied to clipboard!
The following table summarizes the configuration options available for the extract-field-action Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
| field * | Field | The name of the field to extract | string | ||
| headerOutput | Header Output | If enable the action will store the extracted field in an header named CamelKameletsExtractFieldName | boolean | False | |
| headerOutputName | Header Output Name | A custom name for the header containing the extracted field | string | none | |
| strictHeaderCheck | Strict Header Check | If enabled the action will check if the header output name (custom or default) has been used already in the exchange. If so, the extracted field is stored in the message body, if not, the extracted field is stored in the selected header (custom or default). | boolean | False | |
| trimField | Trim Field | If enabled we return the Raw extracted field | boolean | False |
* = Fields marked with an asterisk are mandatory.
23.2. Dependencies Copy linkLink copied to clipboard!
23.2.1. Quarkus dependencies Copy linkLink copied to clipboard!
23.3. Usage Copy linkLink copied to clipboard!
23.3.1. Camel JBang usage Copy linkLink copied to clipboard!
23.3.1.1. Prerequisites for JBang Copy linkLink copied to clipboard!
- Install JBang.
You have executed the following command:
jbang app install camel@apache/camel
jbang app install camel@apache/camelCopy to Clipboard Copied! Toggle word wrap Toggle overflow
23.3.1.2. Running a route with JBang Copy linkLink copied to clipboard!
Suppose you have a file named route.yaml with this content:
You can now run it directly through the following command.
camel run route.yaml
camel run route.yaml
23.3.2. Knative Action Copy linkLink copied to clipboard!
You can use the extract-field-action Kamelet as an intermediate step in a Knative binding.
extract-field-action-binding.yaml
23.3.3. Kafka Action Copy linkLink copied to clipboard!
You can use the extract-field-action Kamelet as an intermediate step in a Kafka binding.
extract-field-action-binding.yaml