Skip to content

Message

Raymond Meester edited this page Mar 14, 2023 · 1 revision

What is a message?

Every message consists of a body, headers and attachements:

Headers

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.

What types of headers are there?

The header value can be set as:

  1. Constant: A fixed value
  2. XPATH: Values are set from the message body with a xpath expression.
  3. JSONPATH: Values are set from the message body with a jsonpath expression.
  4. Simple: Values are set with Simple expressions.
  5. Groovy: Values are set with a Groovy expressions.

Headers in Assimbly

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>

How to create a header?

There are two ways to create a header

  1. Settings --> Headers --> Create header
  2. Flows --> Create flow --> Endpoint (From/To/Error) --> Header

An example of a header with 5 key/value pairs:

Headers

After creation a header can be selected on every endpoint. It's thus possible to use the same header on multiple flows and endpoints.

How to use a header?

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":

Headers

RemoveHeaders

To remove on or multiple headers you can add the following header

Header key: RemoveHeaders (constant) Header value: {pattern} (for example: JMS*)

Clone this wiki locally