public interface AsyncAgent<C extends ClientContext,S extends ServerContext> extends Agent<C,S>, Renderable
NetMessage
. The client keeps a
local copy of the AgentId
in order to be able to cancel the agent any time.
Note that besides a normal Exception this agent may contain a RuntimeException that raised during asynchronous execution on the server. This error will automatically be handled by the clients message receiver.
Modifier and Type | Method and Description |
---|---|
void |
doOnClientSideCancellation()
Is called by the
TaskManager when an AgentId is being cancelled. |
void |
doOnMessageError()
Processes the error contained in the agent that was received in a message.
|
void |
doOnMessageReceived()
Is called on the client side when the agent has been received in a NetMessage
and does not contain an error.
|
void |
doOnServerSideCancellation()
Is called by the
AgentExecutorTask when a cancellation has been detected. |
void |
executeForResponse()
This method is called on an asynchronous agent only, before it is returned within the
NetResponse.
|
SessionId |
getKillerSessionId()
Tells which foreign user has cancelled the agent
|
int |
getMessageTimeout()
Returns the async execution timeout
|
boolean |
isAsync()
Tells whether the agent should be executed asynchronously on the server
in which case it is sent back to the client via a NetMessage.
|
boolean |
isIgnoreMessageError()
Tells whether errors are being ignored by the client when the agent is
received in a message.
|
boolean |
isNoReturn()
Tells whether this async agent should never be returned to the sender within a NetMessage.
|
boolean |
isTimedOut()
Tells whether the agent has been cancelled due to an async execution timeout on server side.
|
void |
setAsync(boolean isAsync)
If this flag is set the agent is executed asynchronously on the server.
|
void |
setCancelledBy(SessionId killerSessionId)
Sets the agent into the cancelled state.
|
void |
setIgnoreMessageError(boolean isHandleError)
Allows for suppressing automatic error handling.
|
void |
setMessageTimeout(int seconds)
Defines a timeout in seconds for asynchronous execution on server side before the agent is
returned in a message.
|
void |
setNoReturn(boolean isNoReturn)
Tells whether this async agent should never be returned to the sender within a NetMessage.
|
boolean |
wasCancelled()
Tells whether this agent ever has been tried to be cancelled.
|
clearClientParams, doFinallyOnClient, doFinallyOnServer, doInitiallyOnClient, doInitiallyOnServer, doOnResponseConfirmed, doOnResponseError, doOnResponseReceived, executeOnServer, getAgentId, getArgument, getClientParam, getClientParams, getError, getName, getOwnerSessionId, getPriority, getResponseTimeout, getSessionId, getTargetServer, hasClientParam, hasError, hasRun, isPartialResultsEnabled, isReceived, isReceivedInMessage, isReceivedInResponse, isRejectable, putClientParam, sendForBooleanExecution, sendForExecution, sendForSilentExecution, setArgument, setArgument, setFailed, setFinished, setName, setOwnerSessionId, setPartialResultsEnabled, setPriority, setReceivedInMessage, setRejectable, setResponseTimeout, setSessionId, setTargetServer
isOnClient, isOnServer, setClientContext, setServerContext
getClientContext
getServerContext
toDumpString, toDumpString, toString, toString
deepClone
getProcessingDuration, getReceivedTime, getSentTime, getTotalDuration, getTransferDuration, setReceivedTime, setSentTime
getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
getRenderColor, getRenderIcon, getRenderText
boolean isAsync()
setAsync(boolean)
void setAsync(boolean isAsync)
isAsync()
int getMessageTimeout()
void setMessageTimeout(int seconds)
AgentExecutionTimeoutException
. A value of zero indicates that infinite execution is allowed.
Note: a default agent async execution timeout may be set as a ServerStartup
parameter
void doOnMessageReceived() throws java.lang.Exception
Note: This method runs client message receiver thread and thus should not
perform any GUI updates. For GUI updates you should use Agent.doFinallyOnClient()
instead.
java.lang.Exception
void doOnMessageError()
setIgnoreMessageError(boolean)
flag is set.
Note: If the client has got a GUI, this method runs in the EventDispatcher Thread.
boolean isNoReturn()
setNoReturn(boolean)
void setNoReturn(boolean isNoReturn)
setMessageTimeout(int)
,
isNoReturn()
void executeForResponse() throws java.lang.Exception
NetMessage
.
Note that by this way it is possible that an asynchronous agent, which is received in a response, already may have partial results. Further results will be received within a message after the asynchronous execution has finished.
java.lang.Exception
SessionId getKillerSessionId()
boolean isTimedOut()
AgentExecutionTimeoutException
.boolean isIgnoreMessageError()
setIgnoreMessageError(boolean)
void setIgnoreMessageError(boolean isHandleError)
isIgnoreMessageError()
void setCancelledBy(SessionId killerSessionId)
AgentExecutorTask
may
later on discover the cancellation and actually stop the execution.boolean wasCancelled()
void doOnServerSideCancellation()
AgentExecutorTask
when a cancellation has been detected.
Within this method the agent may perform any server-side reaction on cancellation.void doOnClientSideCancellation()
TaskManager
when an AgentId
is being cancelled.
Within this method the agent may perform any client-side reaction on cancellation.
Note that this method is called BEFORE the cancel-request is sent to the server.Copyright © 2014 EsprIT-Systems. All Rights Reserved.