如何在Couchbase中捕获保存或更新事件 [英] How to capture save or update events in Couchbase

查看:64
本文介绍了如何在Couchbase中捕获保存或更新事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在Couchbase中更新或创建文档时进行一些数据操作.

I would like to be able to do some data manipulation when documents are updated or created in Couchbase.

文档可以通过Sync Gateway或我们自己的从http服务中流式传输数据的代码到达我们的数据库中.拥有一个可以拦截所有更新的地方,将是非常不错的.

Documents can arrive in our database either via Sync Gateway or our own code which streams data in from an http service. It would be great to have one place where I can intercept all updates.

我们正在对此数据运行一个Spring Boot REST API,因此这将是拥有拦截器/侦听器的好地方.无论哪种方式,我都倾向于Java解决方案.

We are running a Spring Boot REST API against this data so this would be the good place to have the interceptor/listener. Either way my preference would be for a Java solution.

数据被编写为JSON而不是使用Spring实体,所以我不能使用仅侦听Entity类事件的ApplicationListener.如我错了请纠正我.我可以找到一些珍贵的设置ApplicationListeners的示例,因此我在这里可能错了,但似乎无法正常工作.

The data is written as JSON rather than using Spring entities so I can't use ApplicationListener which only listens to events on Entity classes. Correct me if I'm wrong. I can find precious few examples of setting up ApplicationListeners so I may be wrong here but I can't seem to get it working.

我看到有一个Eventing服务,您可以在其中编写Java脚本,但是由于多种原因,我不愿意这样做.我不希望在平台和语言之间分散我们的API代码,也不确定是否可以在我们的系统上运行事件服务,等等.同样,我也可以公开辩论.

I see that there is an Eventing service where you write Javascript but for a number of reasons I'm not keen to go that way. I'm not keen on fragmenting our API code across platforms and languages, not sure I can run the eventing service on our systems etc. Again, I'm open to debate though.

就我所知,DCP仅剩一个很低的水平了. https://blog.couchbase.com/couchbases-history-everything-dcp/,但看起来像是完成工作的工具.

That leaves DCP only as far as I can tell which seems very low level. https://blog.couchbase.com/couchbases-history-everything-dcp/ but looks like the tool for the job.

问题:是否存在另一种较低级别的方法来捕获Couchbase中JSON对象(不是DCP实体)的JSON对象的更新事件.

The QUESTION: Is there an alternative, less low level, way to catch update events in Couchbase for JSON objects NOT entities other than DCP.

推荐答案

免责声明:我为Couchbase工作,并开发了Java DCP客户端.

Disclaimer: I work for Couchbase and develop the Java DCP client.

如果您已经评估了Eventing服务并认为它不符合您的要求,请官方不支持,> Java DCP客户端也可能值得研究.卡夫卡(Kafka),Spark和Elasticsearch的官方Couchbase连接器都使用它,它们都是开源的,并且都得到了积极维护.

If you've already evaluated the Eventing service and decided it doesn't meet your requirements, the Java DCP client might be worth looking into even though it's not officially supported. It's used by the official Couchbase connectors for Kafka, Spark, and Elasticsearch (all of which are open source) and is actively maintained.

如果您只关心应用程序启动后发生的事件,则用法可以简单到

If you only care about events that happened since your app started up, usage can be as simple as registering a callback and starting the event stream. Things get a bit more complicated if you need to remember your place in the stream and resume later (to process events that occurred while you were offline, for example), but there's example code for that case too.

DCP协议本身有据可查.如果您决定走这条路,那么最好至少阅读该文档的 Architecture 部分.另请注意,由于不支持Java DCP客户端,因此该API可能会更改,恕不另行通知. (官方支持该库并提供更友好的API是我们的长期目标之一,但我们尚未做出任何承诺.)

The DCP protocol itself is well documented. If you decide to go this route, it might be good to read at least the Architecture section of that documentation. Also be aware that because the Java DCP Client is unsupported, the API can change without notice. (Officially supporting the library and providing a friendlier API are among our long-term goals, but we haven't committed to anything yet.)

这篇关于如何在Couchbase中捕获保存或更新事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆