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.
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 ?
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.
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
* @return the InternalWorkOrderRequest that was removed.
public InternalWorkOrderRequest _remove(
String p_networkId, Priority p_priority)
InternalWorkOrderRequest retval = null;
/*lock the queue from other threads*/
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*/
System.out.println("value after removing retval after synchronized block:"+retval);
m_logger.debug("_remove(" + retval + ')');
catch (NoSuchElementException e)
m_logger.debug("_remove(): nothing to remove");
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?
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
We have checked that also. There is no exception occurring while removing from the queue.
Can you create a small self contained demo program which reproduces the error ?