fis*_*lom 1 recursion sleep webservice-client asp-classic thread-sleep
我有一个经典的 ASP 页面,它调用外部 Web 服务。实际过程是这样的:
'[Part0 : Call the external webservice]
wsResponse = setConfirmation(...)
' [PART1: external webservice is responding]
if not wsResponse is Nothing then
'....Process the response from the webservice according to wsResponse
code =wsResponse.getCode
if code = 'C' then
'We confirm the transaction and call a storedprocedure in SqlServer
else
'if code is different from C, we assume, the transaction status is 'not confirmed' or 'cancelled'
'[PART2: no answer from external webservice]
Else
'so wsReponse is nothing..We don't get any answer from the external webservice
'transaction is not confirmed
'the transaction status is set to 'not confirmed' in database
Run Code Online (Sandbox Code Playgroud)
所以我想做的是,在第 2 部分(当没有从外部 Web 服务得到答案时),等待 30 秒,然后在数据库中发送“未确认”状态。所以我想再次执行 PART0,即:再次调用外部 Web 服务至少 10 次,看看它是否响应。一种递归过程。所以我想了两种方法:
在PART2中,让ASP休眠30秒,然后再次到PART0(调用Web服务),如果仍然没有响应,则写入DB,事务未确认,但如果有响应,则执行PART1。
在PART2中,调用重复PART0至少10次,如果尝试10次后,没有响应,则写入DB,事务未确认。
所以我的问题是:有没有更好的方法来做到这一点,或者哪个或 1 或 2 会更好?另外,对于 1,我们如何才能像在 dotnet 或 PHP 中一样让 ASP 休眠?
感谢您的回答。
问候
这是一个简单的子例程,可以根据需要延迟几秒
Sub MyDelay(NumberOfSeconds)
Dim DateTimeResume
DateTimeResume= DateAdd("s", NumberOfSeconds, Now())
Do Until (Now() > DateTimeResume)
Loop
End Sub
Run Code Online (Sandbox Code Playgroud)
只需在第 2 部分中调用此子例程即可
Call MyDelay(30)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4844 次 |
最近记录: |