Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-635

Asynchronous method can't recognized by java resteasy client

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • 2.2.3.GA
    • jaxrs

      Asynchronous rest method can be implemented but can't be recognized by reasteasy's proxy client

      interface ---------------------------
      @Path("/demoservice")
      public interface DemoService {
      @GET
      @Path("sayHello/

      {name}")
      @Produces("application/json")
      public Person sayHello(@PathParam("name") String hello);

      }

      implements ------------------------


      @Path("/demoservice")
      public class DemoServer extends BaseEIPService implements DemoService {
      public DemoServer() { System.out.println(" DemoServer start"); }

      //@Override
      public Person sayHello(String hello) { Person pss = new Person(); pss.setName(hello); pss.setAge(28); ArrayList<String> books = new ArrayList<String>(4); books.add("Java Book\""); books.add("J2ee Book"); pss.setBooks(books); return pss; }

      @GET
      @Path("sayHello/{name}

      ")
      @Produces("application/json")
      public Person sayHello(final @PathParam("name") String hello,
      final @Suspend(10000) AsynchronousResponse response) {

      System.out.println("asyn say hello");
      Thread t = new Thread() {
      @Override
      public void run() {
      try

      { Person person = sayHello(hello); Response jaxrs = Response.ok(person).build(); response.setResponse(jaxrs); }

      catch (Exception e)

      { e.printStackTrace(); }

      }
      };
      t.start();
      return null;
      }

      when access http://localhost:8080/aop/rest/demoservice/sayHello/test
      sometimes execute Asynchronous method ,sometimes execute sayHello method (when execute Asynchronous method,print System.out.println("asyn say hello");

      I tried many times and found only define two method (one is Asynchronous wrapper) then reasteasy client proxy can recognized
      sayHello method

      but I can't solve the random call problem , and anyone has any better solutions about this problem ?

      thanks !

              patriot1burke@gmail.com Bill Burke (Inactive)
              springcomingagain zhihui wu (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: