在所有群集Weblogic上使会话无效 [英] Invalidate Session at all Cluster Weblogic

查看:78
本文介绍了在所有群集Weblogic上使会话无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将用户会话保存在每个群集的哈希图中.当我需要使其无效时,我将使用指定的会话ID.并在使用常规方法创建的会话无效的会话中使它无效.

i try to save user session in a hashmap on every cluster. and when i need to invalidate it, i will take specified session id. and invalidate it where the session created with normal way to invalidate session.

public class SessionListener implements HttpSessionListener {

 public HashMap<String, HttpSession> sessionHolder = new HashMap<String, HttpSession>();

 @Override
 public void sessionCreated(HttpSessionEvent se) {
  sessionHolder.put(se.getSession().getId(), se.getSession());
 }

 public void invalidate(String sessionId){
  if(this.sessionHolder.get(sessionId)!= null){
   System.out.println("Invalidate session ID : " + sessionId);
   HttpSession session = sessionHolder.get(sessionId);
   session.invalidate();
  } else {
   System.out.println("Session is not created in this cluster ID : " + sessionId);
  }
 }

 @Override
 public void sessionDestroyed(HttpSessionEvent se) {
  System.out.println("Session " + se.getSession().getId() + " has been destoryed");
  sessionHolder.remove(se.getSession().getId());
 }
}

会话将在发生无效的地方消失.但在其他群集会话上仍然可用.

session will perish where invalidate occur. but on other cluster session is still avaliable.

为什么其他群集上的会话仍然静止.以及如何使其他群集上的会话无效.

why the session on other cluster is still. and how to also invalidate session on other cluster.

谢谢.

推荐答案

(最好确认我们是在谈论服务器还是集群-您域的config.xml会有所帮助)

(it would be good to confirm whether we're talking about servers or clusters - the config.xml for your domain would be a help)

会话对象仅由Web容器内的WebLogic Server管理-如果您在另一个服务器或另一个群集中的HashMap中手动创建会话对象的副本,则WebLogic Server不会自动使该副本无效会话对象,因为它在Web容器之外.

The session object is only managed by WebLogic Server inside the web container - if you create a copy of the session object in a HashMap manually either in another server or another cluster entirely, WebLogic Server won't automatically invalidate the copy of that session object, because it's outside of the web container.

WebLogic Server将自动且相当透明地创建HttpSession对象的复制副本,前提是您的< session-descriptor>您的weblogic.xml部署描述符中的元素具有正确的设置(建议将persisted_if_clustered设置为持久存储类型)

WebLogic Server will automatically, and quite transparently create a replicated copy of HttpSession objects provided that your <session-descriptor> element in your weblogic.xml deployment descriptor has correct settings (replicated_if_clustered for persistent-store-type is recommended)

此处提供文档: http://download.oracle.com/docs/cd/E13222_01/wls/docs103/webapp/weblogic_xml.html#wp1071982

最好了解您要在此处实现的目标-跨集群复制不是必需的,除非您正在谈论怪物应用程序或跨广泛的网络段,尽管WebLogic Server支持该功能.

It would be good to understand what you're trying to achieve here - cross-cluster replication shouldn't be necessary unless you're talking about a monster application or spanning a wide network segment, although it is supported with WebLogic Server.

这篇关于在所有群集Weblogic上使会话无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆