Can you help me with spring integration.
I have Integration flow for send post request to other system with http.
Can I get original message after sending it, because I wanna do other operations on success and error.
ErrorHandler just has HttpClientResponse, but response body is empty and I need originalMessage to handle this situation.
The same situation with success response. I don't have original message information to do next operation.
@Configuration
public class IntegrationConfiguration {
@Bean
public IntegrationFlow incChannel(HeaderEnricher enrichHeaders,
HttpRequestExecutingMessageHandler notifyOnArrival) {
return IntegrationFlows
.from("send_notify_to")
.transform(enrichHeaders)
.handle(notifyOnArrival)
.channel("save_success_status_original")
.get();
}
@Bean
public HeaderEnricher enrichHeaders() {
Map<String, ? extends HeaderValueMessageProcessor<?>> headersToAdd =
Collections.singletonMap("Content-Type", new StaticHeaderValueMessageProcessor<>(APPLICATION_JSON_VALUE));
HeaderEnricher enricher = new HeaderEnricher(headersToAdd);
return enricher;
}
@Bean
HttpRequestExecutingMessageHandler notifyOnArrival(@Value("${uri}") String uri,
MappingJackson2HttpMessageConverter messageConverter) {
HttpRequestExecutingMessageHandler handler =
new HttpRequestExecutingMessageHandler(uri + "/api/notify");
handler.setHttpMethod(HttpMethod.POST);
handler.setExpectReply(false);
handler.setMessageConverters(Arrays.asList(messageConverter));
return handler;
}
}