如何获取云端订阅的消息pub/sub?

How to get messages of a subscritpion on the cloud pub/sub?

我想注意无法在 Cloud Pub/Sub(GCP) 订阅者上处理的剩余消息。 我不希望 pub/sub 在没有通知的情况下丢失一些消息。

我知道我无法在 Cloud Pub/Sub(GCP) 中设置死信队列。 所以我正在尝试开发工具或批处理来观看 api 的订阅消息,即 projects.subscriptions.pull(https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/pull?hl=ja).

但我不知道如何用 google-cloud-pubsub:0.26.0-beta 调用 api。 另外,我正在用scala + play开发批处理。

我发现我可以用"gcloud beta pubsub subscriptions pull"命令获取消息但是我没有得到程序可以检查消息是否有一段时间没有处理的发布时间。

请有人帮助我!

Cloud Pub/Sub 客户端库不直接公开 pull 方法,而是提供异步 API 设计用于高效接收消息。您可以使用此异步 API 来接收您的消息。 Java documentation demonstrates how to create a subscriber using this API. If you have specific reasons to want to call the synchronous pull method, then you'll need to generate the gRPC-based library. You can find the instructions on the Service APIs Overview page.