使用 Spring Cloud Stream Kafka 实现函数绑定过程/消费的断路器

发布于 2025-01-12 18:22:56 字数 365 浏览 5 评论 0原文

这是我的示例流程并使用我在应用程序的函数绑定中设置的 bean

我想要向这些函数添加断路器,但它不会工作,因为这些 bean 只是在项目构建期间被读取。目标是:我希望我的断路器能够捕获在从 kafka 主题获取消息之前在流中遇到的所有异常。示例异常(当卡夫卡关闭时,反序列化)我想在断路器中捕获所有异常,以便我可以在电路打开时暂停/启动卡夫卡。

顺便说一句,我已经在我的服务层(业务逻辑将发生的部分)上实现了它。但这仅限于我的服务上的异常,并且无法捕获流中的所有异常。

我正在使用和需要使用的断路器来自 spring.retry。

Here is my sample process and consume bean which I have set in function binding in application

I would like to add a circuit breaker to these functions but it won't work since these beans are just being read during project build. Goal is: I would like my circuit breaker to capture all exceptions that will be encountered during the stream before I get the message from kafka topic. sample exceptions(when kafka is down, deserialization) I would like to capture all of them in circuit breaker so I can pause/start kafka when circuit is open.

Btw, I have already implemented it on my service layer the part where business logic will occur. But that is only limited to the exceptions on my service and won't be able to capture all the exceptions in the stream.

The circuit breaker I'm using and needed to use is from spring.retry.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文