转载自:
http://community.jboss.org/wiki/CanJBossTellMeWhenIDontCloseAConnection
Can JBoss AS tell me when I don't close connections, statements or resultsets?
Yes.
Connections
For connections the configuration is in deploy/transaction-service.xml
<attribute name="Debug">true</attribute>
Starting with 4.0.0, the configuration is in deploy/jbossjca-service.xml
<!--
| The CachedConnectionManager is used partly to relay started UserTransactions to
| open connections so they may be enrolled in the new tx.
-->
<mbean code="org.jboss.resource.connectionmanager.CachedConnectionManager"
name="jboss.jca:service=CachedConnectionManager">
<depends optional-attribute-name="TransactionManagerServiceName">jboss:service=TransactionManager</depends>
<!-- Enable connection close debug monitoring -->
<attribute name="Debug">true</attribute>
</mbean>
Statements and ResultSets
For statements (and from 3.2.4 ResultSets) you can add the following to your -ds.xml (data source xml: oracle-ds.xml, and so on)
<track-statements>true</track-statements>
Like this:
<!--pooling parameters-->
<min-pool-size>10</min-pool-size>
<max-pool-size>20</max-pool-size>
<blocking-timeout-millis>60000</blocking-timeout-millis>
<idle-timeout-minutes>180</idle-timeout-minutes>
<track-statements>true</track-statements>
Closing statements and ResultSets is important if you want to use prepared statement caching and/or don't won't to leak cursors in your database.
Servlets and JSP
From from 3.2.4 this checking is available in the web layer.
Enable the CachedConnectionValve by uncommenting the following in deploy/jbossweb-xxx.sar/server.xml:
<!-- Check for unclosed connections -->
<Valve className="org.jboss.web.tomcat.tc5.jca.CachedConnectionValve"
cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager" ></Valve>
NOTE: From 4.0.0 the CachedConnectionValve should be configured this way:
<Valve className="org.jboss.web.tomcat.tc5.jca.CachedConnectionValve"
cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager"
transactionManagerObjectName="jboss:service=TransactionManager" ></Valve>
JBoss 4.0.0 distribution still had the previous configuration that woulld cause a NullPointerException in CachedConnectionValve.checkTransactionComplete(CachedConnectionValve.java:198).
Once the valve is enabled, the CachedConnectionManager must be registered in deploy/jbossweb-xxx.sar/META-INF/jboss-service.xml.
At the end of the file, uncomment:
<depends>jboss.jca:service=CachedConnectionManager</depends>
Production and Stress Testing
In production you will want to turn these off. You should have found all your leaks during development.
分享到:
相关推荐
该项目是一款基于freeRTOS操作系统和STM32F103x微控制器的手机远程控制浴室温度系统设计源码,共包含1087个文件,包括580个C语言源文件、269个头文件、45个汇编源文件、36个数据文件、36个目标文件、35个编译规则文件、28个包含文件、27个文本文件、6个源文件、3个归档文件。此系统通过手机远程实现对浴室温度的有效控制,适用于智能浴室环境管理。
labview程序代码参考学习使用,希望对你有所帮助。
labview程序代码参考学习使用,希望对你有所帮助。
labview程序代码参考学习使用,希望对你有所帮助。
labview程序代码参考学习使用,希望对你有所帮助。