【问题标题】:HystrixCommand annotation causes Session closed errorsHystrixCommand 注解导致 Session 关闭错误
【发布时间】:2017-08-06 21:43:12
【问题描述】:

我有一个 spring 应用程序,我正在尝试通过 Hystrix 使用断路器模式。我使用@HystrixCommand 注释在我的服务中标记了一个方法。此方法调用了一个没有@HystrixCommand 注释的存储库,它可以正常工作。

但是,简单地添加注释会给我带来一堆运行时异常 - org.hibernate.SessionException: Session is closed!和 java.net.ConnectException。我对@HystrixCommand 或spring 的了解还不够,无法真正了解这里发生了什么。在使用 Hystrix 之前,我需要了解关于我的存储库连接的一些信息吗?我基本上只是按照这里的指南进行操作:https://spring.io/guides/gs/circuit-breaker/

感谢任何反馈或线索。

【问题讨论】:

    标签: java spring hibernate spring-mvc hystrix


    【解决方案1】:

    只需将以下配置添加到您的 properties/yml 文件中

    hystrix.command.default.execution.isolation.strategy: SEMAPHORE
    

    Here is some documentation for further reading

    【讨论】:

    • 有了这个改变,hystrix 将使用相同的线程来执行 -> 所以不可能强制超时。只能限制可能的并行请求。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-25
    • 1970-01-01
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 2021-10-28
    相关资源
    最近更新 更多