I hope you can help me
I have an Stored Procedure
in SQL Server
which takes care of making a call to a API
. (I know it's not the best but it was requested) I have noticed that when notifications stop sending the connection seems to go to sleep, then the first notification fails and generates a time out .
When I make the call to the notification SP , I added a while
that if the one estatus 201
that generates the successful response does not answer me, it will try again up to 3 times. This cycle is fulfilled if the attempts reach 3 or if the answer is different from 201.
I request your support to see what I can add to the condition in the while
or if I do it with a if
to read if time out
it gives, try again since I do not handle programming in SQL
.
I hope you can help me, thanks!
WHILE(@w_intentos <= 3 and @w_retorno <> '201' )
BEGIN
EXEC @w_retorno = bd_ct_virtual..sp_notifica
@i_ref = @w_referencia,
@i_ref_z = @w_referencia_z,
@i_fecha = @w_fecha,
@i_amt = @i_mont,
@i_name = @i_men
SET @w_intentos = @w_intentos + 1
END
UPDATE bd_virtual..bv_mk_log
SET mk_intentos = @w_intentos
Within the sp_notifica the call is made to an assembly that sends the API, although one of the parameters that I send is the time out, I would like to know what to do if the time out is met
select @w_retorno = bd_ct_virtual.dbo.postJson(
@w_url,
@w_poststr,
'',
@w_contenttype,
@w_metodo,
3000, -- time out
@w_authorization)
You can include a wait within the loop to give the process a chance to "wake up":
The following statement will wait 10 seconds:
You would have something like this: