4 Replies Latest reply on Aug 11, 2011 6:20 AM by Alexander Glintschert

    Parallel execution of different RPCs in Errai?

    Alexander Glintschert Newbie



      currently, I have a problem with parallel execution of different RPCs. I use Errai 1.2.2-Final with GWT 2.1 and SmartGWT Pro 2.4. I configured Errai to use the SimpleDispatcher (AsyncDispather is not an option because it does not allow stable access to the session within RPCs - see my other thread to this point). The following problem occurs in Hosted Mode as well as in Web Mode (which runs on a Tomcat 6.0.24-2ubuntu1.7):


      I have two RPC services. The GWT client application invokes the first RPC and registers a callback that is performed if the call has been finished. The RPC invocation returns immediately and the second RPC (which is independent on the first) is invoked as next. For this RPC, another callback is registered to be performed after the end of the RPC.


      This works in most cases. But sometimes (in an erratic way) the second RPC produces an error and its callback is never invoked. In case the error occurs I can see the following:



      An exception is thrown and printed to the log (or stderr) as follows:


      org.jboss.errai.bus.server.NoSubscribersToDeliverTo: for: com.microdiscovery.dbwebapp.dataviewer.client.communication.rpc.ClientFormDataService:RPC.getClientFormData:java.lang.String:java.lang.String::RespondTo:9
          at org.jboss.errai.bus.server.ServerMessageBusImpl.enqueueForDelivery(ServerMessageBusImpl.java:455)
          at org.jboss.errai.bus.server.ServerMessageBusImpl.access$1000(ServerMessageBusImpl.java:49)
          at org.jboss.errai.bus.server.ServerMessageBusImpl$5.run(ServerMessageBusImpl.java:437)
          at org.jboss.errai.bus.server.async.scheduling.PooledExecutorService$SingleFireTask.run(PooledExecutorService.java:224)
          at org.jboss.errai.bus.server.async.scheduling.ThreadWorker.run(ThreadWorker.java:66)
          at java.lang.Thread.run(Unknown Source)



      If I switch on the ErraiBus Monitor, I can see the following actions

      - At first, a REMOTE_SUBSCRIBE is performed for the first RPC.

      - Then, a REMOTE_SUBSCRIBE is performed for the second RPC.

      - After that, a REMOTE_UNSUBSCRIBE is performed for the first RPC.

      - Finally - in cases where RPC calls work correctly - a REMOTE_UNSUBSCRIBE is performed for the second RPC.

      The last step - the REMOTE_UNSUBSCRIBE for the second RPC - is not performed if the exception is thrown.


      I think, there is a race condition somewhere. I tested my application in Firefox 5, Internet Explorer 8 and Google Chrome 13.0. The problem occurs in all three browsers, in Hosted Mode as well as in Web Mode. But in Firefox and Google Chrome it occurs far less frequently than in Internet Explorer. But with Internet Explorer the whole GWT application runs more slowly than with the other browsers (unfortunately, it's only an impression; I don't have exact performance measurements yet).


      One solution for the problem could be to change the implementation to perform the RPCs in a sequential way. But this is not an option for me. My application uses the feature of asynchronous RPCs provided by Errai to enable the user to perform different activities while a time-consuming operation is running in the background. The user should be able to start an analysis and to perform other things in the meantime. Therefore, it is inevitable that one RPC is started while another RPC is not finished yet.


      Does anybody have an idea what the problem is?