2
votes

I m trying to use java dsl configuration of Spring Integration HTTP Outbound gateway. Where i m able to Connect to external rest service. But i want to Intercept request & response payload information into audit table.

Through Spring integration XML configuration, i m able to achieve .

<int:channel id="channel.ext.request">
    <int:interceptors>
        <ref bean="customInterceptor" />
    </int:interceptors>
</int:channel>

customIntercepter is extending ChannelInterceptorAdapter. here i just overriding postSend method and persisting channel info to db table.

public Message<?> postSend(Message<?> message, MessageChannel channel) {
        return message;
}

This is working as expected.

I want to intercept request & response channel information though java dsl. I couldn't get any source. Here is my java dsl config.

@Bean
public IntegrationFlow httpOut() {
        logger.info("IntegrationFlow enabled");

        return IntegrationFlows.from("channel.ext.request")
                .enrichHeaders(getHeaders())
                .handle(Http.outboundGateway("http://hostname/rest/invoke").charset("UTF-8")
                        .httpMethod(HttpMethod.POST).requestFactory(requestFactory()).expectedResponseType(String.class))
                .channel("channel.ext.response").get();
}

Please suggest.

1

1 Answers

1
votes
.channel(MessageChannels.direct("channel.ext.request").interceptor(myInterceptor()))
.handle(...)
.channel(MessageChannels.direct("channel.ext.response").interceptor(myInterceptor()))