Package com.aquima.web.session
Class ConcurrentSessionModificationMonitor
java.lang.Object
com.aquima.web.session.ConcurrentSessionModificationMonitor
- All Implemented Interfaces:
com.blueriq.component.api.store.keyvalue.IKeyspaceEventListener
,org.springframework.beans.factory.DisposableBean
public class ConcurrentSessionModificationMonitor
extends Object
implements com.blueriq.component.api.store.keyvalue.IKeyspaceEventListener, org.springframework.beans.factory.DisposableBean
This component detects when a session is about to be modified by multiple runtime nodes and interrupts the requests
on all but the last request.
A request which is going to (potentially) modify the session must first register the session with this component and unregister when the request is done. This component will write a "guard" key in the key-value store representing the registered request and session. It also receives notifications from the keyspace monitor when other guards are written and can detect if another request for the same session has started. When a concurrent request is detected, all other registered requests for that session are interrupted.
- Since:
- 11.0
- Author:
- Petru Galanton
-
Constructor Summary
ConstructorsConstructorDescriptionConcurrentSessionModificationMonitor
(com.blueriq.component.api.store.keyvalue.IKeyspaceMonitor keyspaceMonitor, com.blueriq.component.api.store.keyvalue.IKeyValueStore keyValueStore) -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
protected String
getNamespacedGuard
(com.blueriq.component.api.IAquimaSession session, String namespace, String token) void
void
Registers a request that is going to modify the given session.void
unregister
(com.blueriq.component.api.IAquimaSession session, String namespace, String token) Unregisters a previously registered request.
-
Constructor Details
-
Method Details
-
destroy
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
Exception
-
onEvent
- Specified by:
onEvent
in interfacecom.blueriq.component.api.store.keyvalue.IKeyspaceEventListener
-
register
public void register(com.blueriq.component.api.IAquimaSession session, String namespace, String token) Registers a request that is going to modify the given session. The request is identified and distinguished from other requests through the token parameter, which should be different for each request (eg. a randomly generated GUID). The namespace parameter helps to group related requests and can be, for example, the HTTP session id.- Parameters:
session
- the session which should be monitored for concurrent modificationsnamespace
- the namespace for this requesttoken
- a unique identifier for this request
-
unregister
public void unregister(com.blueriq.component.api.IAquimaSession session, String namespace, String token) Unregisters a previously registered request. The session, namespace and token parameters must be the same as those used to register. This method should be called at the end of the request.- Parameters:
session
- the session that should no longer be monitored.namespace
- the namespace for the requesttoken
- the unique identifier for the request
-
getNamespacedGuard
-