- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用 @EnableLoadTimeWeaving
与 AspectJ + @Transactional
+ @HystrixCommand
时遇到问题。
所以,我像这样配置了加载时编织:
@EnableLoadTimeWeaving(aspectjWeaving = ENABLED)
@EnableCaching(mode = AdviceMode.ASPECTJ)
@EnableTransactionManagement(mode = AdviceMode.ASPECTJ)
加上仪器配置。
我有一个 bean A,用 @Transactional
注释,其中的方法用 @HystrixCommand
注释。
然后我有一个 bean B,也用 @Transactional
注释,但具有 propagation = Propagation.MANDATORY
,这意味着它需要现有事务,否则会失败。此 bean 中还有一个方法,用 @HystrixCommand
注释。
最终,当我从 bean A 的方法调用 bean B 的方法时,我得到:未找到标记为传播“强制”的事务的现有事务
。
我花了几个小时寻找问题:一切似乎都配置正确,所以我几乎放弃了。然后我尝试从方法中删除 @HystrixCommand
。瞧:事务传播开始正常工作,异常消失了。
所以我想知道:为什么 @HystrixCommand
会破坏事务传播?这是否与我使用加载时编织有关?或者这是预期的行为?有人可以解释一下吗?
最佳答案
您所说的问题可能与 HystrixCommands
在隔离的 thread 中执行这一事实有关。 :
The default, and the recommended setting, is to run HystrixCommands using thread isolation (THREAD) and HystrixObservableCommands using semaphore isolation (SEMAPHORE).
Commands executed in threads have an extra layer of protection against latencies beyond what network timeouts can offer.
Generally the only time you should use semaphore isolation for HystrixCommands is when the call is so high volume (hundreds per second, per instance) that the overhead of separate threads is too high; this typically only applies to non-network calls.
关于java - 加载时编织 (AspectJ) : Hystrix breaks transaction propagation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57217248/
我们发生了一个生产事件,导致一堆线程陷入僵局,服务器停止工作。为了进行调查,我测试了一些具有不同的Spring事务传播的东西,如果我没有记错的话,如果根本没有现有的事务,那么REQUIRES_NEW传
我有一个简单的 CRUD 项目。我有一个使用 Hibernate 5 和 Spring Boot 的简单 CRUD 项目。当我使用@Transactional(propagation = Propag
这是我的问题: 我正在 Java EE/Spring/Hibernate 应用程序上运行批处理。此批处理调用 method1。这个方法调用一个method2,它可以抛出UserException(一个
有人可以解释为什么第一个单元测试类工作而第二个测试类失败并出现锁定等待超时错误? 第一个类: public class Test1 extends AbstractTransactionalJUnit
如果我有以下代码: @Component public class A{ @Transactional(propagation = Propagation.REQUIRED) public void
在 Spring 文档中,对于 NEVER 传播: Execute non-transactionally, throw an exception if a transactionexists. 我想
根据Spring javadoc @Transactional(propagation = Propagation.SUPPORTS) Support a current transaction, e
我将 jHipster 与 Spring Data JPA 一起使用,并具有以下方法: @Transactional(propagation=Propagation.REQUIRES_NEW) pub
我正在使用 spring 和 hibernate,并使用 spring 事务管理器。我有以下方法,它是从另一个事务性方法调用的。 @Transactional (readOnly = true, pr
现在基本设置都可以了,我开始尝试交易。Struts+Spring+Hibernate注解事务管理器。这是 Action 中的示例代码,将调用一个服务类: userService.addUser
我有这样的代码 @Transactional(propagation = Propagation.NESTED) @TransactionConfiguration(transactionManage
方法与有什么区别 @Transactional(propagation = Propagation.SUPPORTS) 还有一个没有@Transactional的方法? 例如: public clas
当启动新事务时,在使用@Transactional(propagation = Propagation.REQUIRED)启动的当前事务中使用@Transactional(propagation =
方法与 @Transactional(propagation = Propagation.SUPPORTS) 有什么区别vs 没有 @Transactional注释? @Transactional(p
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class) public void abc()
每当我尝试 entityManager.flush() 时,我都会收到标题中提到的错误。有趣的是,我的所有模型都在应用程序启动期间在 MySql 上正确创建。 我已经阅读了几个具有类似异常的问题,基本
我正在开发一个 java (spring/hibernate) 应用程序,它是一种限时且数量有限的销售平台。也就是说,我必须在上午 10 点到 11 点的时间段内只销售 1000 张某种类型的卡片。我
@Transactional(rollbackFor = Exception.class) public void foo1() { `/**Some Code**/` } @Transact
我将我正在开发的应用程序从使用 AspectJ 加载时间编织切换到使用 Spring CGlib 代理,并且在我这样做之后,我开始在代码的许多部分中获得 hibernate 延迟加载异常,而在过去有没
我一直在尝试追踪现有 MySQL(5.7,Linux)代码中的错误行为。我对我发现的行为感到震惊/困惑/不高兴当子查询返回错误时: SELECT * FROM charges WHERE Charge
我是一名优秀的程序员,十分优秀!