Hi
You can set a timeout for async calls by calling the SetTimer() method.
See below an example with an async call where the OnTimeout gets called:
Method OnRequest(pRequest As Ens.Request, Output pResponse As Ens.Response) As %Status
{
SET t=$$$OK
SET t=..SendRequestAsync("BOout",pRequest,1,"RequestCompletionKeyOne",)
Set tSC = ..SetTimer("PT10S")
Quit t
}
Method OnResponse(request As %Library.Persistent, ByRef response As %Library.Persistent, callrequest As %Library.Persistent, callresponse As %Library.Persistent, pCompletionKey As %String) As %Status
{
if pCompletionKey="RequestCompletionKeyOne"
{
$$$TRACE("Response for request with CompletionKey RequestCompletionKeyOne has been received")
}
Quit $$$OK
}
Method OnTimeout(request As %Library.Persistent, ByRef response As %Library.Persistent, callrequest As %Library.Persistent, pCompletionKey As %String) As %Status
{
// Subclass responsibility
$$$LOGWARNING(" Timeout Occurred")
Quit $$$OK
}Regards
Stelios
- Log in to post comments