public interface ExecutionControlScriptService
Modifier and Type | Method and Description |
---|---|
void |
asyncSleep(long millis,
AsyncResult result)
Pauses the execution for a specified portion of time.
|
java.lang.String |
deviceId()
Returns the device id of the Device for which the current script is being executed.
|
java.lang.String |
ruleId()
Return rule id of the Rule within which this method is invoked.
|
java.lang.String |
serviceInstanceId()
Returns the id of the service instance subscription within which the current script is executed.
|
void |
stayRunning(AsyncResult result)
When invoked this method remains uncompleted.
|
java.lang.String |
taskId()
Returns task id of the Task within which this method is invoked.
|
void asyncSleep(long millis, AsyncResult result)
sleep
is forbidden because of its blocking behaviour, users can
use this asyncSleep
methods instead to program some delay in the execution they need.
The code desired to proceed after sleep is completed must be supplied as a Closure
as last argument to the method
(following the general concept for asynchronous methods in Groovy scripting of the Iot Manager). Example:
Closure toProceed = {return 'sleep is over, proceeding with next step'}
execution.asyncSleep(3000, toProceed)
Important note: the implementation of this method is not reliable in terms that timer delay is only maintained at runtime.
If there are sudden restarts of the service node executing the asyncSleep
, this method might never complete,
since the runtime timer event would be lost. Users of this method must just have in mind that tasks might hang running here
and they should rely when possible on rule re-triggering strategy to have everything done in such theoretical cases.millis
- delay time in millisecondsresult
- This parameter is about to be skipped in groovy scripts, it only indicates
the method is asynchronous. Instead, a groovy.lang.Closure
can be passed as last argument
to supply a code that needs to proceed execution after the sleep completes asynchronously.void stayRunning(AsyncResult result)
result
- this parameter should be skipped by Groovy code writers, i.e., invocation would look like: execution.stayRunning()
.java.lang.String ruleId()
null
is returned.java.lang.String taskId()
java.lang.String deviceId()
java.lang.String serviceInstanceId()