I have a MarkLogic database with Content Processing Framework (CPF) installed and the CPF pipeline is such that:
- Whenever a document is inserted then it grabs the value of execution-date from the document and schedule a task for that time.
Example:
Sample document:
<sample>
<execution-date>2014-10-20T12:29:10</execution-date>
</sample>
when inserted triggers the CPF action module which reads the value of execution-date field and creates a scheduled task to be executed on the time read from execution-date field.
Following is the XQuery code snippet from the CPF action module that creates the scheduled task:
let $doc := fn:doc( $cpf:document-uri )
let $releasedon := xs:string($doc/sample/execution-date/text())
let $config := admin:get-configuration()
let $group := admin:group-get-id($config, "Default")
let $new-task :=
admin:group-one-time-scheduled-task(
"/tasks/task.xqy",
"/",
xs:dateTime($releasedon),
xdmp:database("SampleDB"),
xdmp:database("Modules"),
xdmp:user("admin"),
(),
"normal")
let $addTask := admin:group-add-scheduled-task($config,$group, $new-task)
return
admin:save-configuration($addTask),
xdmp:log(fn:concat("Task for document Uri: ", $cpf:document-uri, " created"))
Now, when I insert single document then everything works as expected, that is:
- Document inserted successfully
- the CPF action module is triggered successfully
- Scheduled task created successfully.
But, when I try to insert multiple documents using:
xdmp:document-insert("/1.xml",
<sample>
<execution-date>2014-10-21T10:00:00</execution-date>
</sample>,
xdmp:default-permissions(),
("documents"))
,
xdmp:document-insert("/2.xml",
<sample>
<execution-date>2014-10-20T11:00:00</execution-date>
</sample>,
xdmp:default-permissions(),
("documents"))
CPF action module gets triggered successfully (log message can be seen in logs) BUT ONLY one scheduled task gets created.
When looking in MarkLogic Admin Interface I can only find a single scheduled task which is scheduled to run at 2014-10-20T11:00:00
Please let me know what am I doing wrong or is there any configuration I am missing. Any suggestions are welcomed.
Thanks!