-
-
Notifications
You must be signed in to change notification settings - Fork 9
Message
Every message consists of a body, headers and attachements:
Message headers are properties on messages. Each header consist of a key/value pair. For example:
myHeader1=23
myHeader2=someText
In this example 'myHeader1' and 'myHeader2' are the header keys and '23' and 'someText' the header values. A header key is just a name. Values can be set as a constant or by a scripting language (jsonpath, xpath, groovy and simple).
Every message has headers, but every component (protocol) use them differently. For example there are HTTP headers or JMS Headers, whereas file only contains the body. Assimbly (Apache Camel) will automatically convert headers between components. For example JMS Headers to HTTP Headers.
The header value can be set as:
- Constant: A fixed value
- XPATH: Values are set from the message body with a xpath expression.
- JSONPATH: Values are set from the message body with a jsonpath expression.
- Simple: Values are set with Simple expressions.
- Groovy: Values are set with a Groovy expressions.
On a connector flow a header contains 1 or more key/value pairs. Headers can be set on a from, to or error endpoint. When set on the from endpoint all destinations will receive the headers. When set on a to or error endpoint only this specific endpoint will receives the headers.
On routes headers can be set on the XML:
<route>
<from uri="direct:a"/>
<setHeader name="myHeader">
<constant>test</constant>
</setHeader>
<to uri="direct:b"/>
</route>
There are two ways to create a header
- Settings --> Headers --> Create header
- Flows --> Create flow --> Endpoint (From/To/Error) --> Header
An example of a header with 5 key/value pairs:
After creation a header can be selected on every endpoint. It's thus possible to use the same header on multiple flows and endpoints.
You can use a header to set an option with a value. For example set the fileName property of the camel File scheme from a JMS property "X-Originalfilename":
To remove on or multiple headers you can add the following header
Header key: RemoveHeaders (constant) Header value: {pattern} (for example: JMS*)