下面是使用的组件
我有一个web应用程序,它使用粘性会话,我希望使用apache点燃迁移到非粘性会话。我遵循apache点燃的"web会话集群“指南来实现更改。添加了一个负载均衡器,它将循环机制中的通信量路由到配置的节点列表。我在端口8080上运行节点1,在端口9090上运行节点2。两个节点都配置在带状负载均衡器中。
在本指南中提到的配置更改之后,我成功地运行了单个节点。我能够在管理程序中看到apache点燃缓存中的会话和值,使用下面的命令
./ignitevisorcmd.sh缓存会话-缓存-scan
但是,当我启动第二个节点并请求访问节点2时,由于会话信息的不可用性,会话变得无效,应用程序抛出错误。
我怀疑tomcat的节点2在调用"apache- ignite“WebSessionFilter.class之前创建了一个新的会话,而tomcat并不知道已经存在一个会话。然后,当调用org.apache.ignite.cache.websession.WebSessionFilter时,它用org.apache.ignite.cache.websession.WebSessionV2包装新创建的HttpSession,并作为新会话推送到缓存存储。FYI,我确实用很少的对象使用SessionListener初始化会话。
以下是我在这里张贴之前所做的检查/试验
default-config.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!--
Alter configuration below as needed.
-->
<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="cacheConfiguration">
<bean id="igniteCacheConfiguration" class="org.apache.ignite.configuration.CacheConfiguration">
<!-- Cache name. -->
<property name="name" value="session-cache"/>
<!-- Cache mode. -->
<property name="cacheMode" value="PARTITIONED"/>
<property name="backups" value="2"/>
<property name="statisticsEnabled" value="true"/>
<property name="managementEnabled" value="true" />
</bean>
</property>
</bean>
web.xml
<listener>
<listener-class>org.apache.ignite.startup.servlet.ServletContextListenerStartup</listener- class>
</listener>
<filter>
<filter-name>IgniteWebSessionsFilter</filter-name>
<filter-class>org.apache.ignite.cache.websession.WebSessionFilter</filter-class>
</filter>
<!-- You can also specify a custom URL pattern. -->
<filter-mapping>
<filter-name>IgniteWebSessionsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Specify Ignite configuration (relative to META-INF folder or Ignite_HOME). -->
<context-param>
<param-name>IgniteConfigurationFilePath</param-name>
<param-value>default-config.xml </param-value>
</context-param>
<!-- Specify the name of Ignite cache for web sessions. -->
<context-param>
<param-name>IgniteWebSessionsCacheName</param-name>
<param-value>session-cache</param-value>
</context-param>pom.xml
<ignite.version>2.6.0</ignite.version>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-core</artifactId>
<version> ${ignite.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-web</artifactId>
<version> ${ignite.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-log4j</artifactId>
<version>${ignite.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring</artifactId>
<version>${ignite.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<version>1.1.0</version>
</dependency>我需要了解需要做什么才能使网络会话与2个节点一起工作。
发布于 2018-11-28 15:21:52
发现问题的根本原因是我们使用的是SessionRequestListeners,它正在访问会话信息。在Apache之前调用这些侦听器,从而在Ignite可以在Ignite的缓存中找到会话之前创建一个新会话。由于在调用Apache时可以使用新会话,所以它只使用现有会话并缓存它。
解决方案使用的过滤器代替关键侦听器,并移除非关键侦听器及其现在的工作。
删除的org.springframework.web.context.request.RequestContextListener按顺序在IgniteFilter之后添加org.springframework.web.filter.RequestContextFilter
https://stackoverflow.com/questions/52372140
复制相似问题