简体   繁体   English

从 Spanner 读取数据到 PubSub 队列的最佳方法是什么?

[英]What is the best way to read data from Spanner to PubSub Queue?

I need something like a listener which listens to changes in the database.我需要像监听器这样的东西来监听数据库中的变化。 As soon as some change occurs, it inserts the updated row in the pubSub queue.一旦发生一些变化,它就会在 pubSub 队列中插入更新的行。 What is the best way to do this?做这个的最好方式是什么?

It's still in alpha stage, but you could have a look at this:https://github.com/cloudspannerecosystem/spanner-change-watcher它仍处于 alpha 阶段,但你可以看看这个:https://github.com/cloudspannerecosystem/spanner-change-watcher

It's a generic framework for watching a Spanner database for changes by polling tables for new commit timestamps.它是一个通用框架,用于通过轮询表中的新提交时间戳来观察 Spanner 数据库的更改。 It does require the tables that you want to watch for changes to contain a column with the option ALLOW_COMMIT_TIMESTAMP=TRUE and for this column to be filled.它确实需要您要监视更改的表包含一个带有选项ALLOW_COMMIT_TIMESTAMP=TRUE的列,并填充该列。

It contains three main modules:它包含三个主要模块:

  1. google-cloud-spanner-watcher : This a generic framework that watches a Spanner database for changes. google-cloud-spanner-watcher :这是一个通用框架,用于监视 Spanner 数据库的更改。
  2. google-cloud-spanner-publisher : This uses the framework from the point above and publishes all changes to one or more Pubsub topics. google-cloud-spanner-publisher :它使用上述框架并发布对一个或多个 Pubsub 主题的所有更改。
  3. google-cloud-spanner-archiver : This is an example application for consuming the messages from the Publisher which archives all changes in Google Cloud Storage. google-cloud-spanner-archiver :这是一个示例应用程序,用于使用来自 Publisher 的消息,该消息将所有更改存档在 Google Cloud Storage 中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM