WebLogic設置session超時時間
2008年06月05日 星期四 21:23
WebLogic如何設置session超時時間
1 web.xml
設置WEB應用程序描述符web.xml里的<session-timeout>元素。這個值以分鐘為
單位,并覆蓋weblogic.xml中的TimeoutSecs屬性
<session-config>
<session-timeout>54</session-timeout>
</session-config>
此例表示Session將在54分鐘后過期
當<session-timeout>設置為-2,表示將使用在weblogic.xml中設置的
TimeoutSecs這個屬性值。
當<session-timeout>設置為-1,表示Session將永不過期,而忽略在
weblogic.xml中設置的TimeoutSecs屬性值。
該屬性值可以通過console控制臺來設置
2 weblogic.xml
設置WebLogic特有部署描述符weblogic.xml的<session-descriptor>元素的
TimeoutSecs屬性。這個值以秒為單位
<session-descriptor>
<session-param>
<param-name>TimeoutSecs</param-name>
<param-value>3600</param-value>
</session-param>
</session-descriptor>
默認值是3600秒
3,jsp中控制
session.setmaxinactiveinterval(7200);
session是默認對象,可以直接引用,單位秒s
4,servlet中控制
httpsession session = request.getsession();
session.setmaxinactiveinterval(7200);
單位秒s
在weblgoic的console中:xxDomain->Servers->xxServer->Protocols->HTTP 中有一個關于Post Timeout的配置,但這個參數一般使用默認值即可
一般是通過Services-->JDBC-->Connection Pools-->MyConnection(你所建立的連接池名)-->Configration-->Connections 里的Inactive Connection Timeout這個參數來設置的,默認的為0,表示連接時間無限長。你可以設一個時間值,連接超過這個時間值,它會把連接強制放回連接池
<Server AcceptBacklog="62" CompleteHTTPMessageTimeout="480"
CompleteMessageTimeout="480" IdleConnectionTimeout="600"
ListenAddress="" ListenPort="7001" Name="myserver"
NativeIOEnabled="true" ReliableDeliveryPolicy="RMDefaultPolicy"
ServerVersion="8.1.4.0">
是否IdleConnectionTimeout參數
看連接池中高級選項內的Inactive Connection Timeout和Connection Reserve Timeout時多少, 把這兩項設大些試試
如果在兩個文件中同時設置了超時時間,則會以web.xml中為準。
所以在weblogic環境中,最好將web.xml中關于超時的設置刪掉,保持唯一性。
這也是一個客戶發現了問題后,多次實驗后發現的。
<session-param>
<param-name>TimeoutSecs</param-name>
<param-value>7200</param-value>
</session-param>
</session-descriptor>
<session-config>
<session-timeout>30</session-timeout>
這也是一個客戶發現了問題后,多次實驗后發現的。
今天上午聯創科技的一個朋友問題一個他們的問題.出現大量的:
ueue: ‘billproxyqueue’ has been busy for “727″ seconds working on the request “Http Request: /bill/y
nQueryPublic.go”, which is more than the configured time (StuckThreadMaxTime) of “600″ seconds.>
一看明顯是連接超時, 導致的錯誤.
- 程序問題,是不是程序中沒有關閉連接
- 如果程序沒問題,則是weblogic的
StuckThreadMaxTime設置過小而引起的,一般weblogic server 的
StuckThreadMaxTime默認參數是600s,即10分鐘,如果并發量過大,而導致等待處理過多,
導致系統不停的增加線程,造成線程阻塞,你可以把該參數設置大點這個是稍微調大
StuckThreadMaxTime的參數即可.
- 看線程數設置,可適當增加線程數,這個在WLS控制臺中可以調整