Search code examples
marklogic

Can I use Marklogic Replication Alerting to run java


I've been studying marklogic replication alerting

http://docs.marklogic.com/guide/admin-api/flexrep#id_63603

I'm not clear on what specifically the alerting configuration in these examples are accomplishing. Could someone elaborate further? ( to be clear I understand the curl aspects)

Configuring Alerting

Use POST /manage/v2/databases/{id|name}/alert/configs to create the alerting configuration for the master database.

curl -X POST  --anyauth --user admin:admin
--header "Content-Type:application/json" \
-d '{
  "uri": "http://acme.com/alerting",
  "name": "qbfr",
  "description": "alerting rules for query-based flexrep",
  "trigger": [],
  "domain": [],
  "action": [],
  "option": []
   }' \

http://localhost:8002/manage/v2/databases/master/alert/configs

Use POST /manage/v2/databases/{id|name}/alert/actions to create the alert action and apply it to the alert configuration.

curl -X POST  --anyauth --user admin:admin
--header "Content-Type:application/json" \
-d '{
  "name": "log",
  "description": "QBFR log action",
  "module": "/log.xqy",
  "module-db": "master-modules",
  "module-root": "/",
  "option": []
   }' \

http://localhost:8002/manage/v2/databases/master/alert/actions ?uri=http://acme.com/alerting

Generally I would like an alert of data added to the replica from the master to execute a java api client process on the replica node. Can this be done with replication alerting?

Regards Conteh


Solution

  • I haven't used replication alerting, so I can't comment on that. But in general, if you can run a server-side script, you can call out to a Java web server over HTTP. Use the xdmp:http libraries (here if you prefer server-side javascript). And, of course, you'll need your Java web server running and ready to accept HTTP requests. For that you could use Tomcat, Spring Boot, etc.