This forum has been archived. Please start a
new discussion on GitHub
AMI and cancelling the request
I am using AMI to get the results of a long running job on the server. Client may decide to cancel the request. Is there a way I can cancel the current request to the server and remove the callback?
It's not possible to cancel a request. However, you could add a "cancel flag" to your AMI callback implementation, so that it ignores the response from the server.
CORBA has a request cancellation protocol message, that in theory should allow the user to cancel requests. However, there are many problems with this, in particular:
It is prone to race conditions. When the client sends a cancel message, the server might already have sent the response.
It is not possible for the server to simply stop a thread that currently executes an operation, so all it could do would be to suppress a response from being sent to the client. But the server would continue to process the request.
Having the server keep records for which requests responses should be suppressed introduces additional overhead.
Because of these and other problems, no CORBA product ever made user of cancel messages (at least to my knowledge), and we never considered something like this for Ice.
Thanks for your prompt reply and suggestion.