How to prevent selected Camel headers being mapped onto HTTP headers

247 Views Asked by At

I want to enrich a Camel exchange with content fetched from some external web service. However, when calling that service, I do not want all the headers on my incoming exchange to be mapped onto HTTP headers, just some selected ones should be mapped. Hence, I try to use a HeaderFilteringStrategy as follows:

    override fun configure() {
        from(direct("webservice-query"))
            .setHeader("Accept").constant("application/json")
            .setHeader(Exchange.HTTP_PATH)
            .simple("/partner:\${header.$PARTNER_ID_HEADER}")
            .setHeader(Exchange.HTTP_QUERY).constant("attachments=true")
            .enrich(http(partnerDbUrl)
                     .headerFilterStrategy(myHeaderFilterStrategy)
                     .httpMethod(HttpMethods.GET), PartnerAggregationStrategy
                    )
    }

where myHeaderFilterStrategy is an instance of a custom HeaderFilteringStrategy. However, the HTTP component does not use this strategy. Instead, a default HttpHeaderFilteringStrategy is used. Why? What is wrong with the above route configuration? How can I set a custom header filtering strategy, or otherwise prevent unwanted headers polluting the HTTP request?

0

There are 0 best solutions below