每次调用我的函数时,我都会尝试删除 Marklogic 中的计划任务。它应该遍历任务,如果与正确的任务路径类型和时间匹配,则删除任务。但是我得到一个<h1>500 Internal Server Error</h1>
<dl>
<dt>XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected QName_</dt>
<dd></dd>
<dt>in /eval, at 10:20 [1.0-ml]</dt>
代码应该删除任务,如果它存在,然后在部署时添加一个新任务,因此如果它在计划任务中,则删除该任务,然后创建一个新任务。这是我的代码:
def delete_cron
r = execute_query_camel_rest(%Q{
xquery version "1.0-ml";
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
declare namespace group = "http://marklogic.com/xdmp/group";
let $taskPath := "/my/task/path.xqy" (: Replace with .xqy file :)
let $tasks :=
for admin:group-get-scheduled-tasks($config, admin:group-get-id($config, "Default"))
where $task/group:task-path = $taskPath and $task/group:task-type = minutely and $task/group:task-period = 1
return $task
let $deleteTask := admin:group-delete-scheduled-task($config, admin:group-get-id($config, "Default"), $task)
return admin:save-configuration($deleteTask)
},
{
:db_name => @properties["ml.database-name"]
}
)
我希望在我的添加任务功能之前调用删除功能,就像这样..
def add_cron
delete_heartbeat_cron
r = execute_query_camel_rest(%Q{
xquery version "1.0-ml";
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
declare namespace group = "http://marklogic.com/xdmp/group";