gpt4 book ai didi

spring-boot - Spring Cloud Stream 错误处理...错误

转载 作者:行者123 更新时间:2023-12-03 08:44:05 26 4
gpt4 key购买 nike

这不是真正的问题,因为我找到了一种解决方法,但它与文档冲突,所以我想分享和记录它。
仅供引用 Spring Boot 2.1.10 + SCSt 2.1.4 + RabbitMQ binder

我首先实现了官方文档中给出的应用程序本地错误处理程序:

@StreamListener(Sink.INPUT)
public void handle(Person value) {
throw new RuntimeException("BOOM!");
}
@ServiceActivator(inputChannel = Sink.INPUT + ".my-group.errors") // won't work
public void error(ErrorMessage message) {
log.error("Handling ERROR: " + message.getPayload().getMessage());
}

spring.cloud.stream.bindings.input.destination=persons.inputs
spring.cloud.stream.bindings.input.group=my-group

但这并不顺利,至少可以这么说。这是我最终不得不保留的:
@ServiceActivator(inputChannel = "persons.inputs.my-group.errors")

如您所见,发生的事情是我不得不坚持实际的 目的地定义而不是 channel 的;我觉得这很不舒服!我想再次强调,这与此处的官方文档相矛盾: https://docs.spring.io/spring-cloud-stream/docs/current/reference/htmlsingle/#_application_error_handling (另外还有明显的错别字,恕我直言:他们甚至写到destinationName实际上是必需的)

任何人都可以与我分享对这种情况的想法吗?我做对了吗,我认为这是错误的吗?

最佳答案

这是文档中的一个错误;确实,不幸的是,错误 channel 名称中没有使用绑定(bind)名称而不是目标和组,但是现在更改它为时已晚。我们可能会在 future 的版本中做一些事情。

请打开 2 GitHub issues

  • 修复文档
  • 考虑添加一个选项来使用绑定(bind)名称来命名错误 channel 。
  • 关于spring-boot - Spring Cloud Stream 错误处理...错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58814905/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com