Hello everyone,
I have a question: How can a timer function be integrated into Alfresco without causing excessive CPU consumption? Presently, we have an Alfresco rule triggering the execution of a JS script. Within this script, a timer function of the following type is being used:
function wait(sleepDuration) {
var startTimestamp = new Date().getTime();
while (new Date().getTime() < startTimestamp + sleepDuration) { /* Do nothing */ }
}
To clarify, this `wait` function is called before executing the `retrieveModifiedNodes(node)` function. This delay allows SolR time to index. Without it, the retrieval isn't always complete.
However, we've observed that this method logically demands a lot of CPU resources.
We're aware that Alfresco uses the Rhino engine for JavaScript. Therefore, we're seeking the best approach to adopt. For instance, would it be more suitable within the context of Alfresco to use this method instead:
setTimeout(function() {
var modifiedNodes = retrieveModifiedNodes(node);
}, 60000);
Or are there other more appropriate methods available?