Why the original headers weren't copied on success advice

61 Views Asked by At

Why the original headers weren't copied on success advice. After sending message with http outbound adapter I expected receive original message header, but not got it. Only originalMessagePayload is accessible. I see all headers if I don't use advice and after gateway adapter call my post handler. Is't possible add header with advice?

@Configuration
public class MyIntegrationConfiguration {


    @Bean
    HttpRequestExecutingMessageHandler MyFileNotificationEndpoint(@Value("${uri}") String uri) throws URISyntaxException {
        URI uri = UriComponentsBuilder.newInstance()
                .uri(new URI(uri))
                .path("/api2/integration/myFileNotification")
                .build().toUri();

        return Http
                .outboundGateway(uri)
//                .outboundChannelAdapter(uri)
                .httpMethod(HttpMethod.POST)
                .get();
    }

    @Bean
    public IntegrationFlow sendNotifyOnTypingNotification(TypingNotificationToIncomeFileRqTransformer toIncomeFileRqTransformer,
                                                          HttpRequestExecutingMessageHandler myFileNotificationEndpoint) {
        return  f -> f
                .transform(toIncomeFileRqTransformer)
                .enrichHeaders(Collections.singletonMap("Content-Type", APPLICATION_JSON_VALUE))
                .handle(myFileNotificationEndpoint, c -> c.advice(myNotificationEndpointAdvice()))
                .log();
    }

    @Bean
    public Advice myNotificationEndpointAdvice() {
        ExpressionEvaluatingRequestHandlerAdvice advice = new
                ExpressionEvaluatingRequestHandlerAdvice();
        advice.setSuccessChannelName("addRecognitionStatusOnSuccessSend.input");
        advice.setTrapException(true);
        return advice;
    }

    @Bean
    public IntegrationFlow addRecognitionStatusOnSuccessSend() {
        return f -> f
                .enrichHeaders(Collections.singletonMap("addStatus", RECOGNITION_STATUS_MOVED))
                .handle("documentImageService", "addRecognition");
    }

}
0

There are 0 best solutions below