Page History
Configure Session Manager
The Session Manager can be configured by placing the below a property in the application.properties
file. The following values may be used for this property:
Memory
The default implementation, which stores Blueriq Runtime sessions only inside the HTTP session that lives inside the application server that Blueriq Runtime is deployed on.
Code Block |
---|
blueriq.session.session-manager=externalmemory |
This property selects which IAquimaSessionsMap If the property is not set, this implementation is used for session management. The following values may be used for this property:
by default.
External
An implementation which stores
IAquimaSessionsBlueriq Runtime sessions in a key-value store using the available IKeyValueStore
implementation.
Code Block |
---|
blueriq.session. |
session-manager=external |
Note |
---|
An Key-Value Store Component must be |
available |
/enabled in Blueriq Runtime. Look at Key-value store API and default component for more information on how to configure this. |
Best practices for creating a custom IKeyValueStore
implementation
When creating/using a custom implementation to store the Blueriq Runtime session, it is best to keep in mind some best practices:
- chain passivation and activation (an object may reference other objects that must also be passivated and activated)
- when activation occurs, it is best to restore the internal state of an object first and then call activate(ActivationContext) to restore its dependencies
- always store the minimal needed data only - AquimaSession is passivated and activated per request, a high amount of data transfer can negatively impact general application performance
- it must be possible to restore the dependencies by calling getters in the ActivationContext parameter
Activate/passivate pattern
Activate/passivate pattern was introduced as a means of enabling the Session Manager to store its AquimaSessions instances in an external key-value store in order to use the Blueriq Runtime in a clustered environment.
The main pattern used is inspired by Enterprise Java Beans. Before the object is serialized, it is notified of this fact by calling its passivate()
method. The object then has a chance to do any cleanup before serialization. After the object is deserialized its activate(ActivationContext) method is called. The object then has the chance to restore its dependencies.
passivation |
|
activation |
|
Custom Session Manager
Custom implementations of the Session Manager are possible by implementing the IAquimaSessionsMap
interface. First, set the blueriq.session.session-manager
property to a new value:
Code Block |
---|
blueriq.session.session-manager=example |
Then, expose your IAquimaSessionsMap
implementation as a conditional Spring bean in the application context:
Code Block | ||
---|---|---|
| ||
@Bean
@ConditionalOnProperty(name = BlueriqSessionProperties.SESSION_MANAGER, havingValue = "example")
public IAquimaSessionsMap exampleSessionManager() {
return new ExampleSessionManager()
} |
The Blueriq Runtime will automatically disable the other/default Session Manager implementations and use your custom Session Manager instead.
Panel | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
Note |
---|
Before an external session manager is activated, a Key-Value store component must be enabled in Blueriq. Documentation how this can be done can be found here. |
External Session Store
The External Session Store
Custom code