title: RESTEasy Asynchronous Job Service + Spring MVC?
body: <p>I am using the RESTEasy integration with Spring MVC as described here in section "39.2. Spring MVC Integration"
  <a href="http://docs.jboss.org/resteasy/docs/2.0.0.GA/userguide/html/RESTEasy_Spring_Integration.html" rel="nofollow">http://docs.jboss.org/resteasy/docs/2.0.0.GA/userguide/html/RESTEasy_Spring_Integration.html</a></p>
  
  <p>I'd like to experiment with RESTEasy's implementation of the "async job service" as described here:
  <a href="http://docs.jboss.org/resteasy/docs/2.3.4.Final/userguide/html/async_job_service.html" rel="nofollow">http://docs.jboss.org/resteasy/docs/2.3.4.Final/userguide/html/async_job_service.html</a></p>
  
  <p>Reading the doc, my assumption is that RESTEasy will intercept the request and respond with a HTTP 202 and do the job queueing and tracking and create the <code>.../async/jobs</code> endpoint. So I modified my web.xml as described in the documention. Here's what it looks like:</p>
  
  <pre><code>&lt;web-app&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;resteasy.async.job.service.enabled&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;resteasy.async.job.service.base.path&lt;/param-name&gt;
          &lt;param-value&gt;/asynch/jobs&lt;/param-value&gt;
      &lt;/context-param&gt;
  
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;springmvc&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;classpath:springmvc-servlet.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;springmvc&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt; 
  </code></pre>
  
  <p>I tried to test whether this works by making a call to one of my REST services like this (running under Tomcat 6):</p>
  
  <pre><code>POST http://localhost:8080/myservice?async=true
  </code></pre>
  
  <p>According to the documentation this service is supposed to return a HTTP 202 but it returned the normal HTTP 200 as if I had called without the <code>async=true</code> query param. </p>
  
  <p>I didn't change anything else with my services. Am I missing something? </p>
  
  <p>Btw, here's what the service annotation looks like:</p>
  
  <pre><code>@Controller
  @Path("/")
  public class MyServices {
  
      @POST
      @Produces({MediaType.APPLICATION_XML})
      @Path("myservice")
      public Response createMyResource(@Context UriInfo uri, myResource) {
        // create the resource
        // construct and return a OK Response
      }
  }
  </code></pre>
  
  <p>Has anyone tried this successfully? If not, do you have another easy to use alternative for making async calls to RESTEasy RESTful services (that also works with Spring running under tomcat)</p>
  
  <p>Thanks.</p>