我已按照configuration guide for JBoss EAP 7.0 - 21.3.7设置外部化的HttpSessions到JDG
步骤非常简单,我的standalone.xml包含:
<subsystem xmlns="urn:jboss:domain:infinispan:4.0">
<cache-container name="cacheContainer" default-cache="default-cache" module="org.jboss.as.clustering.web.infinispan" statistics-enabled="true">
<transport lock-timeout="60000"/>
<replicated-cache name="default-cache" mode="SYNC">
<locking isolation="REPEATABLE_READ"/>
<transaction mode="BATCH"/>
<remote-store cache="default" socket-timeout="60000" remote-servers="remote-jdg-server1 remote-jdg-server2" passivation="false" preload="true" purge="false" shared="true"/>
</replicated-cache>
</cache-container>
...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<outbound-socket-binding name="remote-jdg-server1">
<remote-destination host="jdbserver1" port="11222"/>
</outbound-socket-binding>
<outbound-socket-binding name="remote-jdg-server2">
<remote-destination host="jdgserver2" port="11222"/>
</outbound-socket-binding>
然后我将jboss-web.xml文件添加到我的应用程序的WEB-INF文件夹中,引用缓存容器和远程存储缓存:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_10_0.xsd"
version="10.0">
<context-root>/myapp</context-root>
<replication-config>
<cache-name>cacheContainer.default-cache</cache-name>
<replication-granularity>SESSION</replication-granularity>
</replication-config>
</jboss-web>
然而它似乎并没有起作用。我测试了在会话中放置属性并重新启动服务器。然后我可以看到它创建了一个新的httpsession,而不是重用前一个,从而错过了之前的参数集。日志不显示任何相关内容。