3 Replies Latest reply on Oct 23, 2011 12:45 AM by jtahlborn

    retrieve intermediate result from a stored proc call

      Hello all:

      I am designing a service, simply put, the clients will send out request to run stored procs, my service will retrieve the results and send them back. It also involves message broker, caching solution etc, but let's leave them out of the picture.

      Here is my design, I used a TaskManager class to manager all tasks, each of which represents client's request and call respective DAO class to fetch d-base result. The task is designed to implement Callable.

      From the TaskManager, I have this line:
      Future<Result> resp = executorService.submit(task);
      Result r = resp.get();
      // code sending results back to client
      I did stress test by sending out 80 requests simultanously, therefore 80 tasks were created and submitted, and results are realized when they become available. Its amazing that the code work just fine. I was actually impressed by the API.

      Now is the problem. Some of my requests that invoke time-consuming stored proc, and it seems the line
      Result r = resp.get();
      blocks untill all results are back, but I want to periodically return the results from the stored proc, say, first 1000 rows are fetched and sent back, and another 1000.

      I can put the "send-response-back-to-client" logic into the task, but I still want the logic to stay insideTaskManager for better management, for instance, I might want to do something in there about the result before sending them back.

      Another reason is that I want to see if the Java API is capable of handling this kind of sceanario.

      Thanks, John