*/
public Object sendMessage(Message msg, int mode, long timeout) throws TimeoutException, SuspectedException {
Vector mbrs=new Vector();
RspList rsp_list=null;
Object dest=msg.getDest();
Rsp rsp;
GroupRequest _req=null;
if(dest == null) {
if(log.isErrorEnabled())
log.error("the message's destination is null, cannot send message");
return null;
}
mbrs.addElement(dest); // dummy membership (of destination address)
_req=new GroupRequest(msg, corr, mbrs, mode, timeout, 0);
_req.setCaller(local_addr);
try {
_req.execute();
}
catch(Exception t) {
throw new RuntimeException("failed executing request " + _req, t);
}
if(mode == GroupRequest.GET_NONE) {
return null;
}
rsp_list=_req.getResults();
if(rsp_list.isEmpty()) {
if(log.isWarnEnabled())
log.warn(" response list is empty");
return null;
}
if(rsp_list.size() > 1) {
if(log.isWarnEnabled())
log.warn("response list contains more that 1 response; returning first response !");
}
rsp=(Rsp)rsp_list.elementAt(0);
if(rsp.wasSuspected()) {
throw new SuspectedException(dest);
}
if(!rsp.wasReceived()) {
throw new TimeoutException("timeout sending message to " + dest);
}
return rsp.getValue();
}