Reputation: 2937
I know I can set the HeaderFilterStrategy for a particular end-point, but...
How does one override the DefaultHeaderFilterStrategy
with a custom strategy that will apply to all routes?
We are using Camel's Servlet Listener. Can we supply something in the configuration (documented here) to replace the DefaultHeaderFilterStrategy
with our own class?
Upvotes: 1
Views: 1129
Reputation: 909
You could create your own implementation of HeaderFilterStrategy
class and refer to it in the endpoint configuration
<lang:groovy id="MyHeaderFilter">
<lang:inline-script>
import org.apache.camel.Exchange
import org.apache.camel.spi.HeaderFilterStrategy
class MyHeaderFilter implements HeaderFilterStrategy {
public boolean applyFilterToCamelHeaders(String headerName, Object headerValue, Exchange exchange) {
return false
}
public boolean applyFilterToExternalHeaders(String headerName, Object headerValue, Exchange exchange) {
return !(headerName in ['desirableHeaderName'])
}
}
</lang:inline-script>
</lang:groovy>
and then
<to uri="activemq:dummy?headerFilterStrategy=#MyHeaderFilter"/>
UPD.
It is also possible to set custom header filter to the whole component
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="headerFilterStrategy" ref="MyHeaderFilter"/>
</bean>
Upvotes: 1