Filter out headers of AMQP message in AMQP inbound adapter

196 views Asked by At

Given I have IntegrationFlow:

IntegrationFlows.from(
    Amqp.inboundAdapter(rabbitConnectionFactory, NTF_INCOMING_CMSF_EVENT_QUEUE)
            .messageConverter(new Jackson2JsonMessageConverter(jacksonObjectMapper))
)
    .get()

I'd like to apply HeaderFilter to the AMQP inbound adapter, but it seems I can only do it later in the pipeline.

Is it possible to filter headers in inbound adapter?

1

There are 1 answers

0
Artem Bilan On

It is possible, but that is called already a HeaderMapper.

See these options of that Amqp.inboundAdapter():

/**
 * Configure the adapter's {@link AmqpHeaderMapper};
 * defaults to {@link DefaultAmqpHeaderMapper}.
 * @param headerMapper the headerMapper.
 * @return the spec.
 */
public S headerMapper(AmqpHeaderMapper headerMapper) {
    this.target.setHeaderMapper(headerMapper);
    return _this();
}

/**
 * Only applies if the default header mapper is used.
 * @param headers the headers.
 * @return the spec.
 * @see DefaultAmqpHeaderMapper#setRequestHeaderNames(String[])
 */
public S mappedRequestHeaders(String... headers) {

For further details see DefaultAmqpHeaderMapper JavaDocs and this respective reference Manual: https://docs.spring.io/spring-integration/docs/5.3.2.RELEASE/reference/html/amqp.html#amqp-message-headers

So, probably what you need is a negation operator (!) on header name patterns.