简体   繁体   English

如何在 spring 启动应用程序中启动和停止 google pubsub 订阅者?

[英]How to start and stop a google pubsub subsriber in spring boot app?

I have implemented a google pubsub topic-subscriber (spring-boot and cloud stream framework) using the spring.io guides example.我已经使用 spring.io 指南示例实现了一个 google pubsub 主题订阅者(spring-boot 和 cloud stream 框架)。

App starts consuming the messages as soon as the app is up.一旦应用程序启动,应用程序就会开始使用消息。 I would like to implement an api where we start and stop the consumption of messages on demand.我想实现一个 api,我们可以在其中开始和停止按需消费消息。

Let's say GET /pubsub/messages -> start the subscriber -> gets messages (synchronous or asynchronous) -> stops the subscriber.假设 GET /pubsub/messages -> 启动订阅者 -> 获取消息(同步或异步) -> 停止订阅者。

Any thoughts would be helpful.任何想法都会有所帮助。

See this answer Stop consume message for Stream listener看到这个答案Stop consume message for Stream listener

You need to add the actuator Boot starter and inject the BindingsEndpoint to stop/start the binding.您需要添加执行器 Boot starter 并注入BindingsEndpoint以停止/启动绑定。

You can set autoStartup to false to prevent the binding from starting immediately.您可以将autoStartup设置为 false 以防止绑定立即开始。

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

相关问题 Spring 启动 GCP PUBSUB 消费者应用程序 - Spring boot GCP PUBSUB Consumer application 在 Google App Engine 中部署 Spring boot gradle 应用 - Deploy Spring boot gradle app in Google App Engine 如何从 Spring Boot App 连接到运行在不同主机上的多个 Google spanner 数据库 - How to Connect to Multiple Google spanner DB running on different host from Spring Boot App 在 Spring Boot 项目中设置属性以部署到 Google App Engine - Setting properties in Spring Boot project for deployment to Google App Engine Spring 和 Google Cloud PubSub - 订阅事件 - Spring and Google Cloud PubSub - subscribing to events Spring 在 Google Cloud App Engine 上启动托管 - Spring Boot hosting on Google Cloud App Engine 在测试中运行应用程序时如何解决 GOOGLE_APPLICATION_CREDENTIALS,Spring 引导? - How to resolve GOOGLE_APPLICATION_CREDENTIALS when running app in test, Spring Boot? 如何在 GCP App Engine 上同时部署 Spring 启动和 React 应用程序? - How to deploy Spring boot and React application together on GCP App Engine? 如何在没有云的情况下使用 Google PubSub Function - How to use Google PubSub without Cloud Function 如何使用 Google Cloud Function 启动和停止 vm 实例? - How can I use a Google Cloud Function to start and stop vm instances?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM