0

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");
    }

}
Shakirov Ramil
  • 1,381
  • 9
  • 13
  • Not clear what you are asking? What header and where you don't see it? – Artem Bilan Dec 02 '20 at 15:47
  • Also, you have no `successExpression` so nothing will be sent to the success channel. – Gary Russell Dec 02 '20 at 15:52
  • What header and where you don't see it? \n any headers added before handle with HttpRequestExecutingMessageHandler. for example Content-Type was added before call it. If I do: .transform(toIncomeFileRqTransformer) .enrichHeaders(Collections.singletonMap("Content-Type", APPLICATION_JSON_VALUE)) .handle(myFileNotificationEndpoint) .handle("documentImageService", "addRecognition") I can get old header (headers.get("Content-type")) or other my logic header – Shakirov Ramil Dec 02 '20 at 15:59
  • Gary, a `defaultExpression` was added starting `5.1.3`: https://github.com/spring-projects/spring-integration/commit/71fd60fda61ab2d9e919aa7e7616938282e2eda9 – Artem Bilan Dec 03 '20 at 15:16
  • Ramil, the code is not readable in the comments. Please, learn how to format the code over here on SO: https://stackoverflow.com/help/how-to-ask – Artem Bilan Dec 03 '20 at 15:18
  • Your problem is still not clear. Where you don't see those header? How is the problem related to `ExpressionEvaluatingRequestHandlerAdvice`? What does your `toIncomeFileRqTransformer` do? – Artem Bilan Dec 03 '20 at 15:19

0 Answers0