An implementation of SessionStore
that relies on the Infinispan Java Client.
Getting started
To use this module, add the following to the dependencies section of your Maven POM file:
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web-sstore-infinispan</artifactId>
<version>4.5.16-SNAPSHOT</version>
</dependency>
Or, if you use Gradle:
compile 'io.vertx:vertx-web-sstore-infinispan:4.5.16-SNAPSHOT'
Using
If this session store is the only one you have in your dependencies, you can initialize it in a generic way:
JsonObject config = new JsonObject()
.put("servers", new JsonArray()
.add(new JsonObject()
.put("host", "server1.datagrid.mycorp.int")
.put("username", "foo")
.put("password", "bar"))
.add(new JsonObject()
.put("host", "server2.datagrid.mycorp.int")
.put("username", "foo")
.put("password", "bar"))
);
SessionStore store = SessionStore.create(vertx, config);
SessionHandler sessionHandler = SessionHandler.create(store);
router.route().handler(sessionHandler);
Otherwise, use the InfinispanSessionStore
type explicitely:
JsonObject config = new JsonObject()
.put("servers", new JsonArray()
.add(new JsonObject()
.put("host", "server1.datagrid.mycorp.int")
.put("username", "foo")
.put("password", "bar"))
.add(new JsonObject()
.put("host", "server2.datagrid.mycorp.int")
.put("username", "foo")
.put("password", "bar"))
);
InfinispanSessionStore store = InfinispanSessionStore.create(vertx, config);
SessionHandler sessionHandler = SessionHandler.create(store);
router.route().handler(sessionHandler);
Configuring
Config entries
The root entries are:
-
servers
: mandatory, a JSON array of server definitions (see below) -
cacheName
: optional, the name of the cache used to store session data (defaults tovertx-web.sessions
) -
retryTimeout
: optional, the retry timeout value in milli-seconds used by the session handler when it retrieves a value from the store (defaults to5000
)
The entries for a server definition are:
-
uri
: optional, a Hot Rod URI -
host
: optional (defaults tolocalhost
) -
port
: optional (defaults to11222
) -
clientIntelligence
: optional (one ofBASIC
,TOPOLOGY_AWARE
,HASH_DISTRIBUTION_AWARE
) -
username
: mandatory -
password
: mandatory -
realm
: optional (defaults todefault
) -
saslMechanism
: optional (defaults toDIGEST-MD5
) -
saslQop
: optional (one ofAUTH
,AUTH_INT
,AUTH_CONF
)
Important
|
If the uri entry is set, the others are ignored.
|
Custom Infinispan Client
For advanced configuration requirements, you can provide a custom RemoteCacheManager
:
InfinispanSessionStore sessionStore = InfinispanSessionStore.create(vertx, config, remoteCacheManager);
Using a different Infinispan version
Switching the version to Infinispan 14 or Infinispan 14 Jakarta requires Java 11.
Switch to Infinispan 14
In order to use Infinispan 14 you need to upgrade all Infinispan related packages.
Maven:
<dependencyManagement> <dependencies> <dependency> <groupId>org.infinispan</groupId> <artifactId>infinispan-bom</artifactId> <version>14.0.14.Final</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
Gradle:
configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'org.infinispan') { details.useVersion '14.0.14.Final' } } }
Switch to Infinispan 14 Jakarta
In order to use Infinispan 14 you need to upgrade all Infinispan related packages and replace some jakarta specific artifacts.
Maven:
<dependencyManagement> <dependencies> <dependency> <groupId>org.infinispan</groupId> <artifactId>infinispan-bom</artifactId> <version>14.0.14.Final</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.infinispan</groupId> <artifactId>infinispan-client-hotrod-jakarta</artifactId> </dependency> <dependency> <groupId>io.vertx</groupId> <artifactId>vertx-web-sstore-infinispan</artifactId> <exclusions> <exclusion> <groupId>org.infinispan</groupId> <artifactId>infinispan-client-hotrod</artifactId> </exclusion> </exclusions> </dependency> </dependencies>
Gradle:
configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'org.infinispan') { details.useVersion '14.0.14.Final' } } } dependencies { implementation (group: 'io.vertx', name: 'vertx-web-sstore-infinispan', version: '4.5.16-SNAPSHOT') { exclude group: 'org.infinispan', module: 'infinispan-client-hotrod' } implementation group: 'org.infinispan', name: 'infinispan-client-hotrod-jakarta', version: '14.0.14.Final' }