RpcDispatcher.callRemoteMethods() problem

2008-07-10
2012-09-06
  • Neelima Yeole
    Neelima Yeole
    2008-07-10

    We are facing some problem with RpcDispatcher.callRemoteMethods() api. Following is the scenario.

    Whenever our client send a WorkOrderRequest to our server, request is added in a queue on server. QueueManager on server replicates the contents of queue on each server node present in a cluster. Our Dispatcher class removes this request from queue and hence from each node. While it is trying to remove WorkOrderRequest, application invokes JGroups api RpcDispatcher.callRemoteMethods() to make remote calls to our remove method. what happening is, we are receiving response from each node but sometimes it does not return value but it returns null.

    For ex:

    response:sender=192.168.9.53:1407, retval=com.ceon.ias.server.InternalWorkOrderRequest@1c11ce0, received=true, suspected=false
    response:sender=192.168.9.53:1425, retval=null, received=true, suspected=false

    Our nodes are not crashed,our remote method is properly returning object but in the response we are getting retval null.[Please note that "suspected=false" in second response ,still "retval is null"]
    Is there any other reason for this to happen ?

     
    • Bela Ban
      Bela Ban
      2008-07-10

      Is this reproduceable ?
      The reason for the null return value could be that the remote method actually did return null, can you check whether this is possible ? Another reason could be that the return value was not serializable, but in this case you should have a warning message that was logged.

       
    • Neelima Yeole
      Neelima Yeole
      2008-07-11

      Thank you for immediate reply Bela.

      This scenario is reproducible.
      Following is our Remote method. We have added SOPs for checking if remote method properly returns value or not.

      /
      * Called by the RpcDispatcher in response to a group wide call to remove an
      * item to the queue.


      * @param p_networkId the networkId of the device for which a request is to
      * be removed.
      * @param p_priority the priority of the queue for which a request is to be
      * removed.


      * @return the InternalWorkOrderRequest that was removed.
      */
      public InternalWorkOrderRequest _remove(
      String p_networkId, Priority p_priority)
      {
      InternalWorkOrderRequest retval = null;

        try
        {
      
           /*lock the queue from other threads*/
           synchronized (m_mutex)
           {
              retval = m_internalQueue.remove(p_networkId, p_priority);
              System.out.println("value after removing retval:"+retval);
      
              /*wake up all the threads that are waiting for the lock to be released*/
              m_mutex.notifyAll();
           }
      
           System.out.println("value after removing retval after synchronized block:"+retval);
      
           if (m_logger.isDebugEnabled())
           {
              m_logger.debug("_remove(" + retval + ')');
           }
        }
        catch (NoSuchElementException e)
        {
           m_logger.debug("_remove(): nothing to remove");
        }
      
        return retval;
      

      }

      After running,it was observed that we are getting

      value after removing retval:com.ceon.ias.server.InternalWorkOrderRequest@19836f8
      value after removing retval after synchronized block:com.ceon.ias.server.InternalWorkOrderRequest@19836f8

      this as output. Remote method is returning non-null object. But still RpcDispatcher.callRemoteMethods() has retval as null. The class we are returning is serializable. Can there be any other reason?

       
      • Bela Ban
        Bela Ban
        2008-07-11

        What if there's an exception removing from the queue ? That would result in a null return value !
        I suggest wrapping this in a try - catch(Throwable) statement, and see whether you ever get a null value

         
    • Neelima Yeole
      Neelima Yeole
      2008-07-11

      We have checked that also. There is no exception occurring while removing from the queue.

       
      • Bela Ban
        Bela Ban
        2008-07-12

        Can you create a small self contained demo program which reproduces the error ?