Starting with version 1.9.0, apollo-portal adds session sharing support so that session sharing can be implemented in cluster deployments of apollo-portal.

Usage

1. JDBC-based session sharing (default)

The default configuration is JDBC-based session sharing.
So clear the session sharing related configuration and configure the database connection, the configuration to be cleared is as follows
spring.session.store-type configuration in the external configuration file (properties/yml)
Environment variables inside the SPRING_SESSION_STORE_TYPE
System Property inside spring.session.store-type

There are several ways to set the database connection, from highest to lowest priority, as follows

1.1 System Property

  1. -Dspring.datasource.url=xxx
  2. -Dspring.datasource.username=xxx
  3. -Dspring.datasource.password=xxx

1.2 Environment variables

  1. export SPRING_DATASOURCE_URL="xxx"
  2. export SPRING_DATASOURCE_USERNAME="xxx"
  3. export SPRING_DATASOURCE_PASSWORD="xxx"

1.3 External configuration files

For example config/application-github.properties

  1. spring.datasource.url=xxx
  2. spring.datasource.username=xxx
  3. spring.datasource.password=xxx

1.4 Table on initializing session for non-mysql databases

If you need to use other databases, you can refer to the other table creation sql provided by spring-session
Please select the corresponding sql script according to the database you are using

2. Redis-based session sharing

There are several ways to set this up, from highest to lowest priority, as follows Note: redis also supports cluster and sentry mode, configured in the standard Spring Data Redis mode (configuration items starting with spring.redis), please study the Spring Data Redis related documentation or consult the Spring Data Group for details

2.1 System Property

  1. -Dspring.session.store-type=redis
  2. -Dspring.redis.host=xxx
  3. -Dspring.redis.port=xxx
  4. -Dspring.redis.username=xxx
  5. -Dspring.redis.password=xxx

2.2 Environment variables

  1. export SPRING_SESSION_STORE_TYPE="redis"
  2. export SPRING_REDIS_HOST="xxx"
  3. export SPRING_REDIS_PORT="xxx"
  4. export SPRING_REDIS_USERNAME="xxx"
  5. export SPRING_REDIS_PASSWORD="xxx"

2.3 External configuration files

For example `config/application-github.properties‘’

  1. spring.session.store-type=redis
  2. spring.redis.host=xxx
  3. spring.redis.port=xxx
  4. spring.redis.username=xxx
  5. spring.redis.password=xxx

3. Do not enable session sharing

There are several ways to set this, in descending order of priority, as follows

3.1 System Property

  1. -Dspring.session.store-type=none

3.2 Environment Variables

  1. export SPRING_SESSION_STORE_TYPE="none"

3.3 External configuration files

For example config/application-github.properties

  1. spring.session.store-type=none