marklogic - MarkLogic - Alternatives to using triggers
问题描述
MarkLogic version : 9.0-6.2
We have a customer collection and a Real Time PUT/POST API that updates each customer document.
Based on the requirement, when a customer phone number is updated, we sometimes have to update the documents of other related customers. For a better response time of the PUT/POST API, we want to update the document to which the change was made and return a success response to the caller, and then, update all other impacted customer documents. Our first thought is to use triggers but coming from relational/RDBMS background, we are looking for any better alternatives to achieve the same. Are there any alternatives to using triggers?
Thanks in advance!
解决方案
If you have custom code that handles the PUT/POST, or if you are able to decorate it (for instance using REST transforms if you are using the built-in REST-api), you can probably extend/decorate the handling to include whatever else needs to be done.
Triggers are a good way to solve this however. They essentially come in two flavors:
- pre-commit
- post-commit
The pre-commit causes the request to wait for the triggered code to fully complete.
The post-commit causes the trigger code to be spawned on the task server queue, so it can take more time to complete, and won't cause delay for the caller.
There are two frameworks that build on top of Triggers:
Depending on the amount or kind of work that needs to be done, these could potentially be of interest to you. CPF is very good at taking many steps of processing in a very robust, but slow way.
Alerting combines the reverse query feature of MarkLogic to decide if and which alerting rules (to which action code can be attached) should be applied. Very useful if you want to monitor incoming messages for particular keywords for instance.
HTH!
推荐阅读
- python - Pandas:如何仅删除列末尾的最后一个连字符
- google-forms - 如何根据其他用户过去的回复使 Google 表单自动填充?
- c - 我知道一个地址,但我应该如何判断在哪个部分?使用C的全局区域或堆区域或堆栈区域
- json - 如何解决“手势 RangeError(索引)捕获的异常:无效值:有效值范围为空:0”
- c++ - 什么会使多边形算法中的点仅在正向和反向运行时才能正常工作?
- php - PHP:如何使用键->值对每两个分隔符将一个字符串分解为一个数组
- kubernetes - 将 GKE 集群拆除为“全新”状态而不删除它?
- scala - Spark——自定义reduce函数保存到磁盘然后上传到s3
- javascript - XMLHttpRequest 返回事件对象而不是实际数据
- fortran - Fortran 将未知大小的文件读入数组