原文網址:https://ifun01.com/8OB29FZ.html

使用atomikos时,事务默认超时时间是100000毫秒,超过这个时间,提交事务就会抛出异常com.atomikos.icatch.RollbackException: Prepare: NO vote。

今天总算通过bing找到了答案,记录一下。

在网上很多说的要设置com.atomikos.icatch.max_timeout和com.atomikos.icatch.default_jta_timeout,居然都没说怎么设置,集成Spring的情况下,第一时间想到在bean的属性里配置,结果没找到(default_jta_timeout可以在org.springframework.transaction.jta.JtaTransactionManager中找到defaultTimeOut属性与之匹配,但是max_timeout没有找到,官方文档(https://www.atomikos.com/Documentation/JtaProperties)也没说,只是说设置max_timeout和UserTransaction.setTransactionTimeout()是一个意思,结果我配置了半天,没有效果)。最后搞明白了,需要在classpath下建一个jta.properties(或者transactions.properties)文件(事务管理器的配置),来配置事务相关属性,如下是我的jta.properties。

default_jta_timeout与com.atomikos.icatch.max_timeout的区别:default_jta_timeout表示开启事务时,默认的超时时间,max_timeout表示最大的超时时间,0表示无限时间。如果default_jta_timeout设置的值超过了max_timeout,会自动将超时时间截断,使用max_timeout的值(日志会打印出来)。

# SAMPLE PROPERTIES FILE FOR THE TRANSACTION SERVICE
# THIS FILE ILLUSTRATES THE DIFFERENT SETTINGS FOR THE TRANSACTION MANAGER
# UNCOMMENT THE ASSIGNMENTS TO OVERRIDE DEFAULT VALUES;
# Required: factory implementation class of the transaction core.
# NOTE: there is no default for this, so it MUST be specified!
com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory
com.atomikos.icatch.log_base_name = tmlog
com.atomikos.icatch.tm_unique_name = com.tlw.bpm.engine.atomikos.spring.jdbc.tm
com.atomikos.icatch.console_file_limit = 10000
com.atomikos.icatch.console_file_count = 10
com.atomikos.icatch.console_log_level = ERROR
com.atomikos.icatch.enable_logging=false
#atomikos log日志过虑
com.atomikos.icatch.max_actives=-1
# Set base name of file where messages are output
# (also known as the 'console file').
#
com.atomikos.icatch.console_file_name = tm.out# Size limit (in bytes) for the console file;
# negative means unlimited.
#
# com.atomikos.icatch.console_file_limit=-1# For size-limited console files, this option
# specifies a number of rotating files to
# maintain.
#
# com.atomikos.icatch.console_file_count=1# Set the number of log writes between checkpoints
#
# com.atomikos.icatch.checkpoint_interval=500# Set output directory where console file and other files are to be put
# make sure this directory exists!
#
# com.atomikos.icatch.output_dir = ./# Set directory of log files; make sure this directory exists!
#
# com.atomikos.icatch.log_base_dir = ./# Set base name of log file
# this name will be  used as the first part of
# the system-generated log file name
#
# com.atomikos.icatch.log_base_name = tmlog# Set the max number of active local transactions
# or -1 for unlimited.
#
# com.atomikos.icatch.max_actives = 50# Set the default timeout (in milliseconds) for local transactions
# 默认的超时时间 600000 --> 10分钟
com.atomikos.icatch.default_jta_timeout = 600000# Set the max timeout (in milliseconds) for local transactions
# 0表示无限
com.atomikos.icatch.max_timeout = 6000000# The globally unique name of this transaction manager process
# override this value with a globally unique name
#
# com.atomikos.icatch.tm_unique_name = tm# Do we want to use parallel subtransactions? JTA's default
# is NO for J2EE compatibility
#
# com.atomikos.icatch.serial_jta_transactions=true# If you want to do explicit resource registration then
# you need to set this value to false.
#
# com.atomikos.icatch.automatic_resource_registration=true# Set this to WARN, INFO or DEBUG to control the granularity
# of output to the console file.
#
# com.atomikos.icatch.console_log_level=WARN# Do you want transaction logging to be enabled or not?
# If set to false, then no logging overhead will be done
# at the risk of losing data after restart or crash.
#
# com.atomikos.icatch.enable_logging=true# Should two-phase commit be done in (multi-)threaded mode or not?
# Set this to false if you want commits to be ordered according
# to the order in which resources are added to the transaction.
#
# NOTE: threads are reused on JDK 1.5 or higher.
# For JDK 1.4, thread reuse is enabled as soon as the
# concurrent backport is in the classpath - see
# http://mirrors.ibiblio.org/pub/mirrors/maven2/backport-util-concurrent/backport-util-concurrent/
#
# com.atomikos.icatch.threaded_2pc=false# Should shutdown of the VM trigger shutdown of the transaction core too?
#
# com.atomikos.icatch.force_shutdown_on_vm_exit=false

如果是spring不是用的springBoot:

Spring的配置文件

<!-- Atomikos 事务管理器配置 -->
<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"init-method="init" destroy-method="close">
<!-- <property name="startupTransactionService" value="false" /> -->
<!-- close()时是否强制终止事务 -->
<property name="forceShutdown" value="false" /></bean><!-- Atomikos UserTransaction配置 -->
<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"></bean>
<!-- JTA事务管理器 -->
<bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager"><ref bean="atomikosTransactionManager" />
</property><property name="userTransaction"><ref bean="atomikosUserTransaction" /></property>
</bean>
<tx:annotation-driven transaction-manager="txManager" proxy-target-class="true" />

如果您在编写java过程中有出现问题,如果不嫌弃小编我学历浅薄,欢迎添加我的微信一起讨论,感谢您的支持!微信号:atgeretg
大神您觉得还可以的话请您打赏,您的十分满意是小编的无限动力。

解決com.atomikos.icatch.RollbackException: Prepare: NO vote相关推荐

  1. 使用atomikos分布式事务报com.atomikos.icatch.RollbackException: Prepare: NO vote异常解决办法

    发现后台使用atomikos进行事务提交时报javax.transaction.RollbackException: Prepare: NO vote,造成这个事务的主要原因是使用atomikos时, ...

  2. 解决spring boot项目中Caused by: com.atomikos.icatch.RollbackException: Prepare: NO vote异常

    项目使用 spring boot 框架构建,持久层使用 hibernate,用 atomikos 做分布式事务管理,今天在写一个业务时,因为是需要从腾讯地图api接口拿到数据循环保存到自己本地库中,所 ...

  3. 解决多数据事务提交异常nested exception is javax.transaction.RollbackException: Prepare: NO vote,atomikos版本3.9.3

    使用atomikos时,事务默认超时时间是100000毫秒,超过这个时间,提交事务就会抛出异常 nested exception is javax.transaction.RollbackExcept ...

  4. mysql char(36)_MySQL中char(36)被認為是GUID導致的BUG及解決方案

    轉載地址:http://www.cnblogs.com/end/archive/2012/12/26/2834068.html (近日正好有一個項目需要用到C#來操作MySQL數據庫,遇到這個奇怪的問 ...

  5. oracle11g ora00838,管理oracle11g內存設置 解決ora-02097 ora-00838 ora-00845報錯問題

    Oracle對內存的管理的 優化從未間斷,從8i到11g不斷地提出新的管理概念.每個本版都對內存管理進行了簡化:1.8i->9i:PGA的自動管理;2.9i->10g:SGA的自動管理;3 ...

  6. (原創) 如何解決移除DSP Builder後,在Matlab殘留錯誤訊息的問題? (SOC) (DSP Builder) (Matlab)...

    Abstract若在Matlab安裝過DSP Builder,日後將DSP Builder移除後,只要一起動Matlab就有錯誤訊息,該如何解決呢? Introduction 使用環境:Matlab ...

  7. 騰訊大廈有39層的問題解決方案。

    [size=large]問題:[/size] 腾讯大厦有39层,你手里有两颗一抹一眼的玻璃珠.当你拿着玻璃珠在某一层往下扔的时候,一定会有两个结果,玻璃珠碎了或者没碎.大厦有个临界楼层.低于它的楼层, ...

  8. 解決 Tomcat 5.0.x % include file ... % 的中文亂碼問題

    解決 <%@ include file="/global/topright.html" %> 的中文亂碼問題 要解決這個問題,當然最簡單的就是在每個被 include ...

  9. 【FAQ】使用 LOAD 載入外部中文字檔 *.TXT, 中文字卻成為亂碼之解決

    準備一有中文內容之文檔(*.TXT) 加入以下代碼 trace("initializing app");var variables:LoadVars = new LoadVars( ...

最新文章

  1. 对话云知声李霄寒:不计成本研发芯片,探索语音之外的“硬”实力
  2. Google ToolBar 3.0 Beta试用
  3. pytorch实现性别检测
  4. Head First JSP---随笔七
  5. Hi3516A开发--I2C/SPI读写命令
  6. android拍照识别人脸,Android 人脸识别拍照demo
  7. 实战演练:通过伪列、虚拟列实现SQL优化
  8. 用lfw99.9的提取出来的特征在wuxiang的上面测试出来的结果
  9. 24.两两交换链表中的节点
  10. node-7.2.1 already installed, it's just not linked
  11. 专为Mac用户设计的创建图形模式软件:Patternodes 2.4.4
  12. Linux文件系统(七)---系统调用之open操作(二) 之 get_unused_fd
  13. 精选PHP毕业设计12套——源码+论文完整资源
  14. Java基础Day05
  15. fopen w和 w+属性的区别
  16. 使用deepin 20作为开发环境
  17. 支持两个USB Type-C接口都能投屏的便携显示器方案
  18. 域控内使用策略部署和软件分发
  19. 【打通复数域】复数矩阵的实数等效表示
  20. gmod服务器文件,Garry’s Mod|Gmod服务器架设教程(四)挂载创意工坊插件

热门文章

  1. 网络渗透测试——抓包QQ图片
  2. SQL优化经典案例合集
  3. 牛半仙的妹子Tree(Nowcoder)
  4. 美图插上卡显示无服务器,美图账户云服务器
  5. 使用正则表达式来判断邮政编码是否正确
  6. 7-14保持安全社交距离的重要性 最小生成树板子题
  7. Flutter应用名称语言国际化
  8. 垂死病中惊坐起,好好锻炼来得及
  9. 弹窗广告代码及网页弹窗代码分析
  10. eslint-disable的使用