« Return to Thread: async call issue

async call issue

by Sanjiv Jivan :: Rate this Message:

Reply to Author | View in Thread

Hi,
I created an issue for this but figured I'd post my question incase anyone else had encountered a similar issue.
 
Making an async call to a service prevents subsequent calls to the service from being made prior to when the async method on the server completes execution.

Consider the Lingo test case org.logicblaze.lingo.example.ExampleTest#testClient

Change the delay in ExampleServiceImpl.asyncRequestResponse(String stock, ResultListener listener) to 35 seconds.

public void testClient() throws Exception {
   // START SNIPPET: simple

   // lets lookup the client in Spring
   // (we could be using DI here instead)
   ExampleService service = (ExampleService) getBean("client");

   // regular synchronous request-response
   int i = service.regularRPC("Foo");
   System.out.println("Found result: " + i);

   // async request-response
   TestResultListener listener = new TestResultListener();
   service.asyncRequestResponse("IBM", listener);

   //------------> sanjiv : new test code
   int ret = service.regularRPC("foo");
   System.out.println("return value is " + ret);
   //------------> sanjiv : end new test code

   // the server side will now invoke the listener
   // objects's methods asynchronously
   // END SNIPPET: simple

   listener.waitForAsyncResponses(2);

   System.out.println("Found results: " + listener.getResults());
}

In the example above, the async call is made (which runs for 35 seconds on the "server"). However when the next call of "ret = service.regularRPC("foo");" is made on the client, it blocks and eventually times out.

If we call an asynchronous call instead of service.regularRPC, that message is never received by the server.

This is the same behaviour when the destination is a Queue or a Topic.
 
Thanks,
Sanjiv

 « Return to Thread: async call issue