Microservices integration
Spring Boot¶
For Spring Boot usage please refer to Spring Boot article.
Micronaut¶
Redisson integrates with Micronaut framework.
Supports Micronaut 2.0.x - 4.x.x
Usage¶
1. Add redisson-micronaut
dependency into your project:
Maven
<dependency>
<groupId>org.redisson</groupId>
<!-- for Micronaut v2.0.x - v2.5.x -->
<artifactId>redisson-micronaut-20</artifactId>
<!-- for Micronaut v3.x.x -->
<artifactId>redisson-micronaut-30</artifactId>
<!-- for Micronaut v4.x.x -->
<artifactId>redisson-micronaut-40</artifactId>
<version>3.38.1</version>
</dependency>
Gradle
// for Micronaut v2.0.x - v2.5.x
compile 'org.redisson:redisson-micronaut-20:3.38.1'
// for Micronaut v3.x.x
compile 'org.redisson:redisson-micronaut-30:3.38.1'
// for Micronaut v4.x.x
compile 'org.redisson:redisson-micronaut-40:3.38.1'
2. Add settings into application.yml
file
Config structure is a Redisson YAML configuration - single mode, replicated mode, cluster mode, sentinel mode, proxy mode, multi cluster mode, multi sentinel mode
NOTE: Setting names in camel case should be joined with hyphens (-).
Config example:
Upgrade to Redisson PRO with advanced features.
Cache¶
For Micronaut Cache usage please refer to Micronaut Cache article.
Session¶
Redisson provides Micronanut Session store implementation. Extra settings to HttpSessionConfiguration object:
Setting name | Type | Description |
---|---|---|
micronaut.session.http.redisson.enabled | java.lang.Boolean | Enables Session store |
micronaut.session.http.redisson.key-prefix | java.lang.Integer | Defines string prefix applied to all objects stored in Redis. |
micronaut.session.http.redisson.codec | java.lang.Class | Data codec applied to cache entries. Default is Kryo5Codec codec. |
micronaut.session.http.redisson.update-mode | java.lang.String | Defines session attributes update mode.WRITE_BEHIND - session changes stored asynchronously.AFTER_REQUEST - session changes stored only on SessionStore#save(Session) method invocation. Default value. |
micronaut.session.http.redisson.broadcastSessionUpdates | java.lang.Boolean | Defines broadcasting of session updates across all micronaut services. |
Config example:
micronaut:
session:
http:
redisson:
enabled: true
update-mode: "WRITE_BEHIND"
broadcast-session-updates: false
Quarkus¶
Redisson integrates with Quarkus framework and implements Quarkus Cache.
Supports Quarkus 1.6.x - 3.x.x
Native image with RemoteService. Click to expand
To use RemoteService in native image add dynamic-proxy.json and reflection-config.json files in quarkus.native.additional-build-args
setting.
-H:DynamicProxyConfigurationResources=dynamic-proxy.json,-H:ReflectionConfigurationFiles=reflection-config.json
dynamic-proxy.json:
reflection-config.json:
Usage¶
1. Add redisson-quarkus
dependency into your project:
Maven
<dependency>
<groupId>org.redisson</groupId>
<!-- for Quarkus v1.6.x - v1.13.x -->
<artifactId>redisson-quarkus-16</artifactId>
<!-- for Quarkus v2.x.x -->
<artifactId>redisson-quarkus-20</artifactId>
<!-- for Quarkus v3.x.x -->
<artifactId>redisson-quarkus-30</artifactId>
<version>3.38.1</version>
</dependency>
Gradle
// for Quarkus v1.6.x - v1.13.x
compile 'org.redisson:redisson-quarkus-16:3.38.1'
// for Quarkus v2.x.x
compile 'org.redisson:redisson-quarkus-20:3.38.1'
// for Quarkus v3.x.x
compile 'org.redisson:redisson-quarkus-30:3.38.1'
2. Add settings into application.properties
file
Config structure is a flat Redisson YAML configuration - single mode, replicated mode, cluster mode, sentinel mode, proxy mode, multi cluster mode, multi sentinel mode
NOTE: Setting names in camel case should be joined with hyphens (-).
Below is the configuration example for a single Redis or Valkey node setup.
quarkus.redisson.single-server-config.address=redis://localhost:6379
quarkus.redisson.single-server-config.password=null
quarkus.redisson.threads=16
quarkus.redisson.netty-threads=32
Use quarkus.redisson.file
setting to specify path to a config file.
3. Use Redisson
Upgrade to Redisson PRO with advanced features.
Cache¶
For Quarkus Cache usage please refer to Quarkus Cache article.
Helidon¶
Redisson implements Helidon CDI extension for Redis.
Supports Helidon 1.4.x - 4.x.x
Usage¶
1. Add redisson-helidon
dependency into your project:
Maven
<dependency>
<groupId>org.redisson</groupId>
<!-- for Helidon v1.4.x - v2.5.x -->
<artifactId>redisson-helidon-20</artifactId>
<!-- for Helidon v3.x.x -->
<artifactId>redisson-helidon-30</artifactId>
<!-- for Helidon v4.x.x -->
<artifactId>redisson-helidon-40</artifactId>
<version>3.38.1</version>
</dependency>
Gradle
// for Helidon v1.4.x - v2.5.x
compile 'org.redisson:redisson-helidon-20:3.38.1'
// for Helidon v3.x.x
compile 'org.redisson:redisson-helidon-30:3.38.1'
// for Helidon v4.x.x
compile 'org.redisson:redisson-helidon-40:3.38.1'
2. Add settings into META-INF/microprofile-config.properties
file
Config structure is a flat Redisson YAML configuration - single mode, replicated mode, cluster mode, sentinel mode, proxy mode, multi cluster mode, multi sentinel mode
Below is the configuration example for Redisson instance named simple
.
org.redisson.Redisson.simple.singleServerConfig.address=redis://127.0.0.1:6379
org.redisson.Redisson.simple.singleServerConfig.connectionPoolSize=64
org.redisson.Redisson.simple.threads=16
org.redisson.Redisson.simple.nettyThreads=32
3. Use Redisson
For injection without @Named annotation use instance name - default
.
Upgrade to Redisson PRO with advanced features.