Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Marklogic Replication Alerting to run java

Tags:

marklogic

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

like image 211
conteh Avatar asked Jun 11 '26 00:06

conteh


2 Answers

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.

like image 168
Sam Mefford Avatar answered Jun 23 '26 06:06

Sam Mefford


The alerting configuration is just a way to associate a set of queries with a replication target, so that only documents that match one or more of those queries will replicate. There isn't actually any sort of alerting going on.

The flexrep configuration is associated with an alerting configuration URI, and then any targets that are hava a user configured on them will look for queries associated with that user within the alerting configuration.

By leveraging the alerting API, we avoided having to create a new API for managing queries specific to flexrep.

You only need to create the alerting configuration, create some action that doesn't need to do anything, and then create rules for each user associated with a flexrep target. You don't need to create alerting triggers, or add alerting to your CPF pipeline.

Does that clear things up for you?

like image 25
Wayne Feick Avatar answered Jun 23 '26 06:06

Wayne Feick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!