Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everyone,
I am writing to you mainly because I would like to know your opinion regarding an issue I am having with external reloads using Qlik /v1/reloads endpoint. I have lots chained reloads and some parallels ones too. Due to this quantity of reloads, I get the error too many requests. Additionally, I have read the documentation, and it states that the reload endpoint is tier 1 and therefore allows 10 requests per minute. Basically, reload 11 that triggers this endpoint with failed the error too many requests.
Based on your experience and opinions, what would be the best approach to deal with sort of problem? Any recommendations and or suggestions is more than welcomed!
Thanks a bunch!
Hi @rolmontero,
I have created a procedure that handles multiple attempts to reload a Qlik Sense Application.
SET vSleepTimeInMilliseconds = 6000; //Dev Note: to avoid HTTP protocol error 429 (Too Many Requests)
SET vMaxNumberOfRetries = 2; // The maximum number of times this Load Script will try to trigger each App Reload
SET vToTimeZone = 'Pacific Time (US & Canada)'; // The Time Zone of the Reaload Dates. Used for Reload Time comparison
// Recommendation: try to set the variables in a way that vSleepTimeInMilliseconds * vMaxNumberOfRetries = 30000
Sub ReloadApp(vAppId, vAppName)
/*
Commands a Qlik Application to start a full reload process
*/
TRACE Trigerring '$(vAppName)' reload process...;
SET ErrorMode = 0; // Ignore errors generated at this point
SET vRestAPI = 'https://yourtenant.us.qlikcloud.com/api/v1/reloads';
SET vRequestBody = '{""appId"":""$(vAppId)"",""partial"":false}';
SET vAttemptNo = 0;
SET vConnectionScriptError = 0;
SET vLoadScriptError = 0;
Do
LET vAttemptNo = $(vAttemptNo) + 1;
TRACE Attempt No. $(vAttemptNo);
// Increase the waiting time after every attempt
LET vWaitingTimeInMilliseconds = $(vSleepTimeInMilliseconds) * $(vAttemptNo);
Sleep $(vWaitingTimeInMilliseconds);
LIB CONNECT TO 'YourQlikReloadRestAPI';
If ScriptError <> 0 Then
SET vConnectionScriptError = 1;
Else
SET vConnectionScriptError = 0;
End if
TempReloadResult:
SQL SELECT
"id"
FROM
JSON (wrap on) "root"
WITH CONNECTION (
BODY "$(vRequestBody)"
)
;
If ScriptError <> 0 Then
SET vLoadScriptError = 1;
Else
SET vLoadScriptError = 0;
End if
DisConnect;
If Not IsNull(TableNumber('TempReloadResult')) Then
DROP TABLE [TempReloadResult];
End If
Loop While (($(vConnectionScriptError) = 1 or $(vLoadScriptError) = 1) and ($(vAttemptNo) <= $(vMaxNumberOfRetries)));
If ($(vAttemptNo) <= $(vMaxNumberOfRetries)) Then
TRACE '$(vAppName)' reload process triggered;
Else
TRACE Failed to trigger '$(vAppName)' reload process;
End If
SET ErrorMode = 1; // Set error mode to its default state = 1
End Sub
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com