Marklogic: Task Queue

From Glitchdata
Jump to navigation Jump to search


  • Use Query Console
  • Execute XQuery
xquery version "1.0-ml";
for $x in 1 to 10
  for $y in 1 to 10
    return xdmp:spawn-function(function(){
      xdmp:sleep(1000)
    })
;

let $id := fn:data(xdmp:host-status(xdmp:host())//*:task-server/*:task-server-id)
return for $x in 1 to 10
 let $_ := xdmp:sleep(1000)
 return 
   element {"current-status"} {
     attribute {"queued"} {xdmp:server-status(xdmp:host(),$id)//*:queue-size/text()},   
     attribute {"being-processed"} {fn:count(xdmp:server-status(xdmp:host(),$id)//*:request-statuses/*)} 
}