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. Use removeHeaders in the routeThis is a gotcha more people encounter. However it's very easy to solve. To remove all headers use a wildcard expression: from(...).removeHeaders("*").to("smtp://....") Similarly to remove all headers except some of your own (myheader1 and myheader2) use a wildcard with a vararg: from(...).removeHeaders("*", "myheader1", "myheader).to("smtp://....") To do this in XML DSL you simply do: <route> <from uri="..."/> <removeHeaders pattern="*" excludePattern="myHeader1,myHeader2"/> <to uri="smtp://..."/> </route> Again to remove only Camel headers but no other transport headers: from(...).removeHeaders("Camel*").to("smtp://....") To do this in XML DSL you simply do: <route> <from uri="..."/> <removeHeaders pattern="Camel*"/> <to uri="smtp://..."/> </route>
Use HeaderFilterStrategyAn alternative is that some of the Camel Components supports configuring a custom header filter strategy. |