Remove Headers

The Remove Headers EIP allows you to remove one or more headers from the Message, based on pattern syntax.

Options

The Remove Headers eip supports 0 options, which are listed below.

Name Description Default Type

note

Sets the note of this node.

String

description

Sets the description of this node.

String

disabled

Disables this EIP from the route.

false

Boolean

pattern

Required Name or pattern of headers to remove. The pattern is matched in the following order: 1 = exact match 2 = wildcard (pattern ends with a and the name starts with the pattern) 3 = regular expression (all of above is case in-sensitive).

String

excludePattern

Name or patter of headers to not remove. The pattern is matched in the following order: 1 = exact match 2 = wildcard (pattern ends with a and the name starts with the pattern) 3 = regular expression (all of above is case in-sensitive).

String

Exchange properties

The Remove Headers eip has no exchange properties.

Remove Headers by pattern

The Remove Headers EIP supports pattern matching by the following rules in the given order:

  • match by exact name

  • match by wildcard

  • match by regular expression

Remove all headers

To remove all headers you can use * as the pattern:

  • Java

  • XML

  • YAML

from("seda:b")
  .removeHeaders("*")
  .to("mock:result");
<route>
  <from uri="seda:b"/>
  <removeHeaders pattern="*"/>
  <to uri="mock:result"/>
</route>
- from:
    uri: seda:b
    steps:
      - removeHeaders:
          pattern: "*"
      - to:
          uri: mock:result

Remove all Camel headers

To remove all headers that start with Camel then use Camel* as shown:

  • Java

  • XML

  • YAML

from("seda:b")
  .removeHeaders("Camel*")
  .to("mock:result");
<route>
  <from uri="seda:b"/>
  <removeHeaders pattern="Camel*"/>
  <to uri="mock:result"/>
</route>
- from:
    uri: seda:b
    steps:
      - removeHeaders: "Camel*"
      - to:
          uri: mock:result

Leaking Camel headers when sending to an endpoint

When I send a message to a Camel endpoint such as the Mail component, then the mail include some message headers I do not want. How can I avoid this?

This is a gotcha more people encounter. However, it’s very easy to solve. To remove all headers (see above) use a * expression:

Most components will automatically remove all Camel specific headers (the header key starts with Camel) using the DefaultHeaderFilterStrategy which automatic removes these headers. However if you use a component that does not do this, such as a custom component, or a Camel component which has not been improved to do that, then you can remove all these Camel specific headers using Camel* with the removeHeaders EIP as shown previously on this page.

See Also

Camel provides the following EIPs for removing headers or exchange properties: