March 2018
Intermediate to advanced
34 pages
1h 33m
English
MarkLogic’s Task Server provides a way to schedule work asynchronously. By default, up to 16 tasks will run at the same time on the standard queue, along with 16 tasks on the high-priority queue. Recipes in this chapter show how to remove tasks from the queue, which normally only happens if the queue is wiped by a MarkLogic restart.
There are active tasks being executed on the Task Server, and you’d like to cancel some or all of them.
Applies to MarkLogic versions 7 or higher
xqueryversion"1.0-ml";declarenamespacehs="http://marklogic.com/xdmp/status/host";declarenamespacess="http://marklogic.com/xdmp/status/server";let$max-task-duration:=xs:dayTimeDuration("PT7M")let$min-retries:=2(: set $user-ids to desired sequence of ids :)let$user-ids:=xdmp:get-current-userid()let$compare-time:=fn:current-dateTime()-$max-task-durationfor$hostasxs:unsignedLonginxdmp:hosts()let$task-server-id:=xdmp:host-status($host)//hs:task-server-idlet$requests:=xdmp:server-status($host,$task-server-id)//ss:request-status[not(xs:boolean(ss:canceled))(: and ss:user = 7071164300007443533 :)(: and ss:retry-count >= $min-retries :)andss:request-text="/some/module/uri.xqy"andss:start-time<$compare-time]return(text{"There are currently",fn:count($requests),"matching requests on host",xdmp:host-name($host)},for$requestin$requestslet$request-idasxs:unsignedLong ...
Read now
Unlock full access