Skip to content
𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ

Share the knowledge

𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ

Share the knowledge

Apache Camel – How to remove some or all exchange headers

Posted on April 22, 2016September 25, 2021 By sastrija

While dealing with Apache Camel, we normally comes with scenarios where we have to send only message body, but exchange header have lots of unwanted data. In this case we can remove all headers in one single method call.

from(fromEndPoint)
        .removeHeaders("*")
        .to(toEndPoint)

In some other scenarios, we have to remove all headers except few. This can also achieved by using below code:

from(fromEndPoint)
        .removeHeaders("*", "RequiredHeader1", "RequiredHeader2", "RequiredHeader3")
        .to(toEndPoint)

With the above code, it will remove all the headers from exchange, but will keep header values for “RequiredHeader1”, “RequiredHeader2” and “RequiredHeader3”.

Related

Uncategorized

Post navigation

Previous post
Next post
©2026 𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ | WordPress Theme by SuperbThemes