ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcin Skladaniec <mar...@ish.com.au>
Subject XmlRpc Client won't die ...
Date Wed, 13 Oct 2004 06:01:45 GMT
Hello !
I have a XmlRpcClient executing an rpc method on very unreliable 
server. I have to force quit XmlRpcClient.execute() from time to time, 
but I can't. I have even created a separate Thread for it, and I'm 
quitting the Thread after timeout. It is working but not always, when 
server receives xmlrpc request and freezes without any sign of life my 
thread is uninterruptible. Is my approach to this problem right or am I 
missing something ? Does anyone created some other workaround for 
missing timeout in XmlRpc framework ?


This is the impoortant part of my code:


	public SpacialThread(String pRemoteDatabaseURL, String pXmlRpcMethod, 
Vector pXmlRpcParameters) {
		super();
		
		xmlRpcResponse = null;
		
		xmlRpcMethod = pXmlRpcMethod;
		xmlRpcParameters = pXmlRpcParameters;
		// See setResponse
		hasReceivedResponse = false;
		hasBeenInterrupted = false;
		
		try {
			client = new XmlRpcClient(pRemoteDatabaseURL);
		} catch (java.net.MalformedURLException e) {
			logger.error("(hash: " + hashCode() + "): 
java.net.MalformedURLException thrown:\n"
					+ e);
		}
		
		start();
	 }


	public void run() {
		try {
			// This is a blocking call...
			logger.debug("(hash: " + hashCode() + "): Attempting Xml Rpc 
transaction.");
			// Set response explicitly (this should be thread safe?)
			Object response = client.execute(xmlRpcMethod, xmlRpcParameters);
			setResponse(response);
			
			if (isInterrupted()) {
				hasBeenInterrupted = true;
				logger.error("(hash: " + hashCode() + "): Xml Rpc transaction 
interrupted explicitly. Exiting. (Communication with remote 
abandoned)");
			} else {
				logger.debug("(hash: " + hashCode() + "): Returned from Xml Rpc 
transaction.");
			}
		
		} catch (Exception e) {
			// Something else gone wrong... log the error and leave the 
exception for reference.
			logger.error("(hash: " + hashCode() + "): Xml Rpc transaction 
interrupted abormally. Exiting. (Communication with remote 
abandoned)");
			setException(e);
		} finally {
			// Regardless of the situation, clean up and release the network 
resources (hopefully)
			logger.debug("(hash: " + hashCode() + "): Xml Rpc transaction 
finilizing - releasing resources.");
			client = null;
		}
	}

Cheers
Marcin Skladaniec


Mime
View raw message