在使用atomikos 事务管理中,当并发数超过50的时候会产生异常如下:
java.lang.IllegalStateException:Max number of active transactions reched:50

原因:

atomikos的默认配置中 transactions.properties中:

#SAMPLEPROPERTIESFILEFORTHETRANSACTIONSERVICE#THISFILEILLUSTRATESTHEDIFFERENTSETTINGSFORTHETRANSACTIONMANAGER#UNCOMMENTTHEASSIGNMENTSTOOVERRIDEDEFAULTVALUES;#Required:factoryimplementationclassofthetransactioncore.#NOTE:thereisnodefaultforthis,soitMUSTbespecified!#com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory#Setbasenameoffilewheremessagesareoutput#(alsoknownasthe'consolefile').##com.atomikos.icatch.console_file_name=tm.out#Sizelimit(inbytes)fortheconsolefile;#negativemeansunlimited.##com.atomikos.icatch.console_file_limit=-1#Forsize-limitedconsolefiles,thisoption#specifiesanumberofrotatingfilesto#maintain.##com.atomikos.icatch.console_file_count=1#Setthenumberoflogwritesbetweencheckpoints##com.atomikos.icatch.checkpoint_interval=500#Setoutputdirectorywhereconsolefileandotherfilesaretobeput#makesurethisdirectoryexists!##com.atomikos.icatch.output_dir=./#Setdirectoryoflogfiles;makesurethisdirectoryexists!##com.atomikos.icatch.log_base_dir=./#Setbasenameoflogfile#thisnamewillbeusedasthefirstpartof#thesystem-generatedlogfilename##com.atomikos.icatch.log_base_name=tmlog#Setthemaxnumberofactivelocaltransactions#or-1forunlimited.##com.atomikos.icatch.max_actives=50(原因)#Setthedefaulttimeout(inmilliseconds)forlocaltransactions##com.atomikos.icatch.default_jta_timeout=10000#Setthemaxtimeout(inmilliseconds)forlocaltransactions##com.atomikos.icatch.max_timeout=300000#Thegloballyuniquenameofthistransactionmanagerprocess#overridethisvaluewithagloballyuniquename##com.atomikos.icatch.tm_unique_name=tm#Dowewanttouseparallelsubtransactions?JTA'sdefault#isNOforJ2EEcompatibility##com.atomikos.icatch.serial_jta_transactions=true#Ifyouwanttodoexplicitresourceregistrationthen#youneedtosetthisvaluetofalse.##com.atomikos.icatch.automatic_resource_registration=true#SetthistoWARN,INFOorDEBUGtocontrolthegranularity#ofoutputtotheconsolefile.##com.atomikos.icatch.console_log_level=WARN#Doyouwanttransactionloggingtobeenabledornot?#Ifsettofalse,thennologgingoverheadwillbedone#attheriskoflosingdataafterrestartorcrash.##com.atomikos.icatch.enable_logging=true#Shouldtwo-phasecommitbedonein(multi-)threadedmodeornot?#Setthistofalseifyouwantcommitstobeorderedaccording#totheorderinwhichresourcesareaddedtothetransaction.##NOTE:threadsarereusedonJDK1.5orhigher.#ForJDK1.4,threadreuseisenabledassoonasthe#concurrentbackportisintheclasspath-see#http://mirrors.ibiblio.org/pub/mirrors/maven2/backport-util-concurrent/backport-util-concurrent/##com.atomikos.icatch.threaded_2pc=false#ShouldshutdownoftheVMtriggershutdownofthetransactioncoretoo?##com.atomikos.icatch.force_shutdown_on_vm_exit=false

修改默认配置中的:

com.atomikos.icatch.max_actives=50------改为更大就可以解决