32.4. Running Remote Tasks
If authorization is disabled on the server then anyone may execute remote tasks once they have been installed. Otherwise, only users with
EXEC
permissions will be allowed to run previously installed tasks. If a remote task has additional users specified, via the getAllowedRole
method, then users must also belong to this role to execute the script.
To execute a previously deployed task call
execute(String taskName, Map parameters)
on the desired cache. The following example demonstrates executing a task with the name sampleTask
:
import org.infinispan.client.hotrod.*; import java.util.*; [...] String TASK_NAME = "sampleTask"; RemoteCacheManager rcm = new RemoteCacheManager(); RemoteCache remoteCache = rcm.getCache(); // Assume the task takes a single parameter, and will return a result Map<String, String> params = new HashMap<>(); params.put("name", "value"); String result = (String) remoteCache.execute(TASK_NAME, params);