【问题标题】:How to set Method level Transaction timeout in WebSphere Liberty?如何在 WebSphere Liberty 中设置方法级事务超时?
【发布时间】:2019-05-17 12:53:00
【问题描述】:

我已经开发了 Java 应用程序并且正在使用 wlp18 服务器。在此之前,我使用 Jboss 运行了我的应用程序。在 Jboss 中,我使用 @TransactionTimeout 注释在我的 EJB 中设置方法级事务超时。当我迁移到 WebSphere Liberty 时,我无法找到方法级别的事务超时。而不是使用 .xml 配置来设置类级别事务超时,如下所示,

 <session name="class-name">
   <global-transaction transaction-time-out="1000">
 <session>

有没有办法在方法级别设置事务超时,或者为什么不能在 WebSphere Liberty 中设置方法级别事务。

【问题讨论】:

    标签: java jboss websphere websphere-liberty


    【解决方案1】:

    如果您有权访问 UserTransaction 对象,则可以使用该对象设置事务超时:

    @Resource
    UserTransaction tx;
    
    public void doSomething() {
      tx.setTransactionTimeout(123);
      tx.begin();
      // ...
    }
    

    【讨论】:

    • 运行良好。我在班级级别添加了注释“@TransactionManagement(TransactionManagementType.BEAN)”以将 CMT 更改为 BMT
    猜你喜欢
    • 1970-01-01
    • 2020-09-17
    • 2016-08-13
    • 1970-01-01
    • 1970-01-01
    • 2016-09-09
    • 2018-10-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多