How to avoid sending some or all message headers?
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?
Use removeHeaders in the route
This is a gotcha more people encounter. However it's very easy to solve. To remove all headers use a wildcard expression:
Similarly to remove all headers except some of your own (myheader1 and myheader2) use a wildcard with a vararg:
To do (a similar thing) in XML DSL you simply do:
Again to remove only Camel headers but no other transport headers:
To do this in XML DSL you simply do:
An alternative is that some of the Camel Components supports configuring a custom header filter strategy.
This allows you to implement the
org.apache.camel.spi.HeaderFilterStrategy interface, where you can filter unwanted headers.
Though its often easier to use the removeHeaders in the Camel route as shown above.