简体   繁体   中英

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. 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

It's a generic framework for watching a Spanner database for changes by polling tables for new commit timestamps. 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.

It contains three main modules:

  1. google-cloud-spanner-watcher : This a generic framework that watches a Spanner database for changes.
  2. google-cloud-spanner-publisher : This uses the framework from the point above and publishes all changes to one or more Pubsub topics.
  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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