0

I would like to create an AsyncRestTemplate which also has Http Caching enabled...

From what I've read, it seems as though I need to explicitly enable Http Caching by creating a AsyncHttpClient (How do I create an async caching http client? ).

Unfortunately, I can't find any RestTemplate (or ClientHttpRequestFactory) constructors that allow me to utilise the HttpAsyncClient interface (frustratingly the HttpComponentsAsyncClientHttpRequestFactory takes a CloseableHttpAsyncClient abstract class??).

I'm currently contemplating writing a custom ClientHttpRequestFactory as an input to the AsyncRestTemplate - am I on the right path?

Related:

Community
  • 1
  • 1
Nick Grealy
  • 24,216
  • 9
  • 104
  • 119
  • The answer in your other question gives you basically all you need. You pass the constructed client to a `HttpComponentsAsyncClientHttpRequestFactory` which you pass to an `AsyncRestTemplate`. Not sure why you would need to create more/custom classes? Just 3 beans in your configuration. And obviously `RestTemplate` will not give you that as you should be looking at the `AsyncRestTemplate` instead. – M. Deinum May 01 '17 at 08:35
  • @M.Deinum, except `HttpComponentsAsyncClientHttpRequestFactory` constructor takes a `CloseableHttpAsyncClient`, and not a `CachingHttpAsyncClient`... am I missing something? – Nick Grealy May 01 '17 at 11:39

0 Answers0