/ / Wie wird eine Protokollwarnung gestartet, um ein einfaches Laden von Dokumenten in Marklogic auszulösen? - marklogic, marklogic-9

Wie startet man einen Log-Alarm, um bei einem einfachen Dokument in Marklogic zu starten? - marklogic, marklogic-9

I"m trying to get a simple log/email alert to fire in Marklogic and am following the examples in the documentation. However I cannot seem to execute an action.

My steps:
[1] create config and insert.
[2] create action and insert.
[3] create rule and insert.

Meine Alarmaktion ist so einfach wie xdmp:log("some message", "alert"). Ich habe eine log.xqy und in die Module dB geladen. Wenn ich anrufe alert:invoke-matching-actions("config uri", fn:doc("/mydocs/doc.xml"), ). Ich erwarte, dass die Warnungsaktion in mein Protokoll schreibt, aber dies ist nicht der Fall, und ich kann sie scheinbar nicht sinnvoll debuggen.

(:_________**set up config**___________________:)
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
let $config := alert:make-config(
"test-config-uri",
"test-config-name",
"Alerting config for test",
`<alert:options/>`
)
return alert:config-insert($config);



(:_______**set up action**___________________:)
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
let $action := alert:make-action(
"test-action-xdmp:log",
"log to ErrorLog.txt",
xdmp:modules-database(),
xdmp:modules-root(),
"/modules/alert/log.xqy",
`<alert:options>`content modified`</alert:options>`
)
return  alert:action-insert("test-config-uri", $action);



(:_____**create rule**____________________:)
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
let $rule := alert:make-rule(
"test-rule-name",
"test-rule-name-desc",
0,
cts:word-query("Radiohead"),
"test-action-xdmp:log",
`<alert:options/>`
)
return  alert:rule-insert("test-config-uri", $rule);




(:_______**run rule against content**____________________:)
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
alert:invoke-matching-actions("test-config-uri",
<doc>Radiohead</doc>, <options/>);




(:_______**log.xqy**_______________________________:)
xquery version "1.0-ml";
let $msg := "Content was modified. New update alert. "
let $level := "alert"
return xdmp:log($msg, $level);

Antworten:

0 für die Antwort № 1

Ich habe folgendes von QConsole ausgeführt, was funktioniert hatgut für mich. Stellen Sie sicher, dass log.xqy an Ihrem Ende ordnungsgemäß erstellt wurde. Es muss sich um eine Textdatei in der Moduldatenbank handeln, die dem App-Server zugeordnet ist, mit dem Sie das ausführen alert:invoke-matching-actions Funktion..

(:_________**set up config**___________________:)
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
if (empty(alert:config-get("test-config-uri"))) then
let $config := alert:make-config(
"test-config-uri",
"test-config-name",
"Alerting config for test",
<alert:options/>
)
return alert:config-insert($config)
else ()

;

(:_______**set up action**___________________:)
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
if (empty(alert:get-actions("test-config-uri", "test-action-xdmp:log"))) then
let $action := alert:make-action(
"test-action-xdmp:log",
"log to ErrorLog.txt",
xdmp:modules-database(),
xdmp:modules-root(),
"/modules/alert/log.xqy",
<alert:options>content modified</alert:options>
)
return  alert:action-insert("test-config-uri", $action)
else ()

;

(:_____**create rule**____________________:)
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
if (empty(alert:get-all-rules("test-config-uri", cts:word-query("test-rule-name")))) then
let $rule := alert:make-rule(
"test-rule-name",
"test-rule-name-desc",
0,
cts:word-query("Radiohead"),
"test-action-xdmp:log",
<alert:options/>
)
return  alert:rule-insert("test-config-uri", $rule)
else ()

;

(:_______**log.xqy**_______________________________:)
let $doc := text {"
xquery version "1.0-ml";
let $msg := "Content was modified. New update alert. "
let $level := "alert"
return xdmp:log($msg, $level);
"}
return
xdmp:eval(
"
xquery version "1.0-ml";
declare variable $uri external;
declare variable $doc external;
xdmp:document-insert($uri, $doc, xdmp:default-permissions())
",
map:new((
map:entry("uri", "/modules/alert/log.xqy"),
map:entry("doc", $doc)
)),
map:entry("database", xdmp:modules-database())
)

;

(:_______**run rule against content**____________________:)
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
alert:invoke-matching-actions("test-config-uri",
<doc>Radiohead</doc>, <options/>)

HTH!