I am trying to build an integration solution where
IntegrationFlows
.from(inBoundGateway)
.enrichHeaders(enrichHeaders())
.transform(dto to externaldto)
.handle(outBoundGateway, advice -> advice.advice(retryAdvice()))
.transform(exetrnaldto to dto)
.get()
@Bean
RequestHandlerRetryAdvice rhra
rhra.setRecoveryCalBack(errorMessgaeRecoverer());
@Bean
ErrorMessageSendingRecoverer errorMessgaeRecoverer
and my outboundgateway is defined as
Http.outboundGateway(uri, resttemplate)
...
.get()
new RestTemplate(requestFactory)
where requestFactory is
TrustStratgey ts = new TrustStratgey(){
public boolean isTrusted(...){
return true;
}
}
SSLContext context = SSLContexts,custom().loaddTrustMaterials(null, ts);
SSLContextFactory cf = new SSLContextFactory(context, new NoopHostnameVerifier());
HttpClientBuilder clientBuilder ..
clientBuilder.setSSLSocketFactory()
Happy path works fine, the problem i am facing is with not so happy path.
- When Api call returns Error response .transform(exetrnaldto to dto) fails and client get 500
- I want to translate error resposne json as well to my json
- How do i handle error situations.
My questions are;
- How to handle errors.
- In error conditions how to stop flow not to transform
- How to send status code in response from outbound to client (this is important)
- How to handle error like typical @Controller Advice @ErrorHandler mechanism or similar.
Hope Garry get to see this post, couldnt find any answers, i looked through many books and forums, feels like Java DSL is not widely used or commented yet.