axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eng-list" <>
Subject RE: Need way to cancel an operation
Date Tue, 13 Dec 2005 16:47:49 GMT
Hi Wade,

Yes, it's too bad there isn't an Axis cancel feature that closes the
underlying socket (which would gracefully interrupt the send, wait or
read in process) and return.  I was hoping there was one that I just
hadn't found yet.

Thanks for the response and tips!


-----Original Message-----
From: Wade Chandler [] 
Sent: Monday, December 12, 2005 6:18 PM
Subject: Re: Need way to cancel an operation

--- Eng-list <> wrote:

> Hi,
> I have a Java client application that performs an operation in a Java 
> SwingWorker thread.  From the GUI thread I want to allow the user to 
> cancel the operation if the cancel button is pressed.  I don't see a 
> way to send down a cancel command by way of Stub, AxisEngine, Service,

> ...
> How can a cancel operation be performed?
> Thanks in advance,
> -Kevin

I have had the same problem.  I ended up using a big no no for now:
Thread.stop() and making calls from a separate thread in the client.  To
be able to do this clean you would have to copy HTTPSender (I'm assuming
you're using http calls), hack Axis to use this class, and have checks
all through out the class.  I didn't even bother getting into which
classes I would want to access, but I'm thinking Boolean cancelled =
cancelled.booleanValue(); would do the trick...notice the non-existent
CancellableHTTPSender (could create this).  Then from inside of there
you would have to constantly check the MessageContext for the property
and bounce out of the code.  Look in really would not be
that hard to do.  

A better way would be to add a property to MessageContext
setCancelled(boolean),isCancelled()...maybe add it to the interface, and
then all the other classes could use it [check the value from inside of
HTTPSender and kick out if it's cancelled].  This really needs to be
something included in Axis.  I mean, you start streaming out the request
from the can easily cancel  here or you are reading the
response ..
can cancel there...or you are waiting on the response to start streaming
back from the URLConnectionStream....interrupt the current thread to
make it throw out an exception from here to get out of the blocking
method [I think an interrupt on the current thread will break a blocking
method call..depends on how it is polling]  That's just an off the top
of my head type of thing though.  It's more complicated and needs
thought through.  Like, if there is processing on the "backend" you
might or might not want to cancel this processing depending on how your
web service operates.  So, there are issues involved, and sometimes you
can't just make the client fall off the map and leave the server running
it's process, but in most cases you should be able to and if it's a
complicated backend cancel thing maybe we could just leave that up to
the web service author.


View raw message