Does anyone already try ZK with Spring boot and Spring session using Redis as storage for session information? I´m trying do something with these 3 components, but it seems the status of every component in a page is not persisted, i think i´m not doing something but i really don´t now what thing is, if some has an example or knows where i can find info about this i will appreciate too much.

2 Answers

yes when using Redis there's at least one catch ... by default it only persists changes to session attributes by calculating a delta.

ZK is storing the ZK-Session (SerializableSession) in a session attribute called javax.zkoss.zk.ui.Session
This session attribute will never change during the lifetime of the session (only nested attributes such as the desktop cache containing the component trees change).
Hence Redis doesn't know about changes in the internal fields of the ZK-Session object and doesn't update the cached value. The Solution is to somehow tell Spring Redis that this session attribute needs to be persisted. As of the current implementation I found that setting the session attribute again with the same value does the trick. To automate this after each ajax request one can implement an ExecutionCleanup listener as follows.

Comments

Side Note: in case you intent to setup clustering -> make sure to use STICKY-sessions. Without them ZK can't synchronize concurrent updates within a session and information gets lost when session updates are written into the Redis cache from 2 different nodes.

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!