在前些天的项目里,发现一个关于WebLogic 缓存和钝化有状态会话EJB 的问题。
简单描述下:
===========================================
当cache-type
设置为NRU 的时候,按照官方文档上的描述:
Lazy Passivation ( NRU )
When lazy passivation is configured by setting cache-type
to NRU
, the container avoids passivating beans, because of the associated systems overhead—pressure on the cache is the only event that causes passivation or eager removal of beans.
- Removes a bean instance from cache when
idle-timeout-seconds
expires, and does not passivate it to disk. This is referred to as a eager remove . An eager remove ensures that an inactive instance does not consume memory or disk resources. - Passivates instances to disk when max-beans-in-cache is reached, even though
idle-timeout-seconds
has not expired.
懒 钝化 (NRU )
当cache-type
被配置为NRU 的时候,容器会回避钝化Bean,因为关系到关联的系统的缓存开销,导致钝化或渴望删除Beans。
- 当经过
idle-timeout-seconds
(闲置时间)时从Cache里直接删除bean,而不是钝化到硬盘上。这被作为一个渴望删除。
一个渴望删除保证了不会耗尽内存和硬盘资源。 - 当达到max-beans-in-cache 时 钝化硬盘上的bean实例,即使没有超过
idle-timeout-seconds
(闲置时间)
=============================================================
也就是说设置成NRU时 如果超过idle-timeout-seconds
时间就会把Cache中的Bean直接干掉。图5-2 也是这么画的。
但项目中始终没有验证出这个结论----即使经过闲置时间,不管超没超过max-beans-in-cache ,也不会从Cache中删除-------开始以为项目本身的框架有一些特殊的实现导致的,后来就做了一个纯净版的ejb sample(见附件)。发现结果还是这样。
难道是Oracle的文档的问题 还是Bug,还是自己在验证中出现了什么差错? 不解!!!
后来添附上Sample 问了一下Oracle。一个月过去了,还是没有答复。
想请教一下大家,原因是什么?
为什么超过 idle-timeout-seconds
时间后没有像官方文档上描述的"直接从内存中删除Bean"?
****************************************************************************
附上相关文档说明:
cache-type
功能
NRU 缓存大小的最小值为 8。如果 max-beans-in-cache 小于 3,WebLogic Server 会对 max-beans-in-cache 使用 8 这个值。
示例
<stateful-session-cache> <cache-type>NRU</cache-type> </stateful-session-cache>
Controlling Passivation
The rules that govern the passivation of stateful session beans vary, based on the value of the beans cache-type
element, which can be: