How do I set a timeout in AsyncRestTemplate?
-
I am using following code :- /*AsyncClientHttpRequestFactory asyncClientHttpRequestFactory = new SimpleClientHttpRequestFactory(); RestTemplate restTemplate = new RestTemplate(); SimpleClientHttpRequestFactory rf = (SimpleClientHttpRequestFactory) restTemplate.getRequestFactory(); rf.setReadTimeout(60000);*/ AsyncRestTemplate asyncRestTemplate = new AsyncRestTemplate(); ListenableFuture<ResponseEntity<X>> futureResponse = null; StringBuilder messageCode = new StringBuilder(); StringBuilder messageText = new StringBuilder(); try { logger.debug("Creating enrollment request."); futureResponse = asyncRestTemplate.exchange(url, HttpMethod.POST, null,responseType); final StringWriter stringWriter = new StringWriter(); futureResponse.addCallback(new ListenableFutureCallback<ResponseEntity>() { @Override public void onSuccess(ResponseEntity result) { try { JAXBContextRegistry.getContext(responseType).createMarshaller().marshal(result.getBody(), stringWriter); handleResponse(request, (X)result.getBody(), callback); } catch (Exception e) { logger.error("Error in parsing response."); logger.error(e.getMessage(),e); } } @Override public void onFailure(Throwable t) { callback.onError("request got failed."); } }); } catch (ResourceAccessException ex) { logger.error("Exception occured during I/O process", ex); } catch (RestClientException ex) { logger.error("Exception occured",ex); } I want to set timeout which was very simple in rest template. Please tell me a way to do the same in async rest template.
-
Answer:
Did you check stackoverflow http://stackoverflow.com/questions/21943662/how-do-i-set-a-timeout-on-springs-asyncresttemplate
Mustafa Al-Saegh at Quora Visit the source
Related Q & A:
- How do I set a Gtk.StatusIcon as Text?Best solution by stackoverflow.com
- How can I set a wireless camera to record on my computer?Best solution by Yahoo! Answers
- How do I set a personal picture as my default in Yahoo?Best solution by Yahoo! Answers
- How do I set a signature for my phone?Best solution by Yahoo! Answers
- How do I set a video as a picture?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.