Google PubSub-获取最新消息 [英] Google PubSub - getting last message

查看:49
本文介绍了Google PubSub-获取最新消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用Google App Engine及其提供的服务.我特别感兴趣的一项服务是云发布订阅.

I am beginning to work with google app engine and the services it offers. One service that I am particularly interested in is the cloud pubsub.

我的计划是拥有一个nodejs socket.io服务器,该服务器订阅某个pubsub主题,并且只要该主题收到发布,它将把该发布发送到所有套接字.

My plan is to have a nodejs socket.io server which subscribes to some pubsub topic and whenever the topic receives a publish it would send that publish to all sockets.

在另一端,我将拥有一个.NET/Java服务,该服务可以将消息发布到各个主题.

At the other end, I would have a .NET/Java service that publishes messages to various topics.

我的问题是-有没有办法获取发布到主题的最新消息?

My question is this - Is there a way to get the last message that was published to a topic?

有可能出现nodejs服务器宕机且发布服务在一段时间内未发布任何内容的情况.

There could be a case where the nodejs server was down and the publishing service didn't publish anything for a while.

如果我使用Redis,则可以进行发布和设置,在pubsub中等效于发布和设置吗?内存缓存会是一个好的解决方案吗?

If I were using Redis, I could do publish and set, what is the equivalent of publish and set in pubsub? Would memcache be a good solution?

谢谢

推荐答案

Google Cloud Pub/Sub没有提供以事务方式发布和写入数据库的方法.您将需要发布到Pub/Sub,并具有一个将最后一个值"写入数据库的订阅者.根据所需的可靠性和持久性,内存缓存可能是一个不错的选择,或者使用DataStore可以提高可靠性.这将提供最终的一致性.

Google Cloud Pub/Sub does no offer a way to transactionally publish and write to a database. You would need to publish to Pub/Sub, and have a subscriber that writes the "last value" to the database. Depending on how reliable and durable you need this, memcache could be a good option, or DataStore for better reliability. This will provide eventual consistency.

这篇关于Google PubSub-获取最新消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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