ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Petersen, Jennifer" <Jennifer.Peter...@cbsa-asfc.gc.ca>
Subject RE: Client side timeout?
Date Tue, 21 Feb 2006 21:43:55 GMT
I am able to manage my own threads .. just not allowed to :)
 
-----Original Message-----
From: John Buren Southerland [mailto:john@southerland-consulting.com]
Sent: February 21, 2006 4:40 PM
To: xmlrpc-user@ws.apache.org
Subject: RE: Client side timeout?



You should still be able to manage your own threads, though that could wander outside of the
thread pool management.

I poked at the code though I would not feel comfortable trying to add a timeout like that,
which is unsupported in a jvm previous to 1.5

I need a better timeout as well.

I just realized that this was on the XMLRPC thread, I had been watching the HttpClient thread
to see if anyone had a response on a proposal for a way to set a user timeout to go along
with the connection and socket timeouts already supported.  That support however, was added
because the underlying jvm started supporting those features on the socket class.  This timeout
would need to be handled in the method execution.

here is what I use in another application for timeouts of httpclient requests:
    private class TimeoutTimer extends TimerTask {
        private HttpMethod method=null;
        private int timeout=0;
        public void setTimeout( int i ) { timeout = i; }
        public int getTimeout() { return timeout; }
        public void setMethod( Object i ) { this.method = (HttpMethod)
i; }
        public HttpMethod getMethod() { return method; }

        public void run() {
            logger.error("Fetch URL Timed Out Due to user timeout of "+
(int) timeout/1000 +" seconds being reached");
            method.abort();
            method=null;
        }
    }

then schedule it (using java 1.5) and execute your method:
    TimeoutTimer timeoutTimer = new TimeoutTimer();
    Timer timer = new Timer();

    //then create your method as usual.....

    timeoutTimer.setMethod(getMethod);
    timeoutTimer.setTimeout(userTimeout);
    timer.schedule(timeoutTimer, userTimeout);
    httpClient.executeMethod(getMethod);
    timer.cancel();

Arguably, their must be a better way.  Does anyone do anything smarter/faster/better?
Thanks, John

On Tue, 2006-02-21 at 15:56 -0500, Petersen, Jennifer wrote:


I'm limited in what I can do because of J2EE/Websphere/Corporate standards. The request is
part of a global transaction running on an applciation server thread in Websphere. As well
there are issues accessing "container managed resources"on application threads.
 
Bottom line is I need an exectue that does not block forever. seems to me that this would
be the norm and an execute that waits for data foever the exception. no?
 
So I am wondering if  there is  technical or spec reason for not supporting it or is it just
oversight? 
ie) what would be involved to add this feature. 
 
thanks.
 
--
Jennifer
 
 
-----Original Message-----
From: John Buren Southerland [mailto:john@southerland-consulting.com]
Sent: February 21, 2006 2:54 PM
To: xmlrpc-user@ws.apache.org
Subject: Re: Client side timeout?




Jennifer,
I have to do it now with a thread implementing a sort of sigalarm, I don't see any other way
to do it.   
Why can you not use another thread? 

On Tue, 2006-02-21 at 14:13 -0500, Petersen, Jennifer wrote: 

I've searched high and low and can't seem to find a way to set a client side timeout on a
request. 



My requirement is to return with an error when a response to a request is not returned within
our SLA (say 2 seconds). Note that I cannot manage threads nor can I control this at the service
level (I don't own the server code).



I know this question has been asked before but I don't see answers/recommendations, other
than a suggestion to 

use commons HttpClient. Is this the recommended approach? any sample code, hint? anyone? :)




thanks.



--

Jennifer
















Mime
View raw message