How to implement asynchronous rest webservice client using RestTemplate?
<p>I want to invoke rest webservice call asynchronously using spring 3.1 rest template. Currently we are using Resttemplate.getForObject method to invoke the rest webservice. Now as per the requirement we have to invoke another webservice method concurrently along with existing one. We are invoking this method call from EJB 2.1 stateless session bean by instantiating the method class. </p>

<p>Sample code is as below:-</p>

<pre><code>public class MyImplServerBean extends EJBObject{
   RestServiceImpl restImpl = new RestServiceImpl(); 
   ArrayList&lt;User&gt; userDetailsList = restImpl.getUserDetails(123);
}

public class RestServiceImpl {

   RestTemplate template = new RestTemplate();

   public ArrayList&lt;User&gt; getUserDetails(int userId){

   ArrayList&lt;User&gt; userList = new ArrayList&lt;User&gt;();
   String url = "http://localhost:7001/myUserService/userId";
   User user = template.getForObject(url, User.class);
   userList.add(user);
   return userList;
}
</code></pre>

<p>We now need to make getUserDetails method call asynchronously. I got the idea using @Async annotation but not aware how to exactly implement.
Can you please help in this.</p>