weblogic 如何进行连接回收

来源:互联网 发布:mac localhost打不开 编辑:程序博客网 时间:2024/06/10 07:32

一、gc回收 web应用 → 连接池回收

weblogic jconnector Garbage Collector Method:(wls api)

WebLogic Server automatically detects connection leaks by leveraging its Java Virtual Machine
(JVM) garbage collector mechanism. When an application component terminates and the
connections it uses become dereferenced, the garbage collector calls the connection object’s
finalize() method.

When the garbage collector calls the finalize() method, if WebLogic Server determines the
application component has not closed the connection, the server automatically closes the
connection by calling the resource adapter’s ManagedConnection.cleanup() method;
WebLogic Server behaves as it would had it received a CONNECTION_CLOSED event upon proper
closure of the application component connection. 

通过JVM垃圾回收机制,wls服务器能自发探测连接泄露,当应用终止而其所使用的连接变为孤儿时,

垃圾回收器就调用连接对象的finalize方法

垃圾回收器调用finalize方法时,如果wls服务器确定是应用没有关闭连接,

wls服务器将调用资源适配器的ManagedConnection的cleanup方法自动关闭连接,

weblogic服务器表现得就像它本来应该接收 应用组件连接的其中某个连接上的一个CONNECTION_CLOSED事件

 

二、程序显式回收 web应用→连接池

Connection.close()方法调用后,weblogic监控到该动作,由连接池回收并管理连接

 

 

三、weblogic的无效链接回收

inactive connection timeout 经过设定时间,回收无效链接

 

 

四、weblogic的连接池自动收缩

Allow Shrinking: 允许自动收缩。如果连接池的初始容量和最大容量不相等,那么当池中的连接大于初始容量时,经过Shrink Frequency时间,如果连接池中的活动连接不高于初始容量个,那么连接池中连接的数量会减少到初始容量大。

原创粉丝点击