/** * <p>Configuration properties to connect HTTP session storage * to the Hazelcast IMDG server. * </p> * <p>Meaning of each: * <ul> * <li><b>use-client</b> Are we a Hazecastl IMDG client or server * </li> * <li><b>client-config-location</b> How to configure the client * </li> * <li><b>map-name</b> Where to save the sessions * </li> * <li><b>sticky-session</b> Can we assume that all requests from the same * user will come to this process, and make optimisations on that basis. * </li> * </ul> * </p> * * @return Properties */ @Bean public WebFilter webFilter() { Properties properties = new Properties(); properties.put("use-client", "true"); properties.put("client-config-location", "hazelcast-client.xml"); properties.put("map-name", Constants.IMAP_NAME_JSESSIONID); properties.put("sticky-session", "false"); log.info("Web properties {}" , properties); return new WebFilter(properties); }
/** * Create a web filter. Parameterize this with two properties, * * <ol> * <li><i>instance-name</i> * Direct the web filter to use the existing Hazelcast instance rather than * to create a new one.</li> * <li><i>sticky-session</i> * As the HTTP session will be accessed from multiple processes, deactivate * the optimization that assumes each user's traffic is routed to the same * process for that user.</li> * </ol> * * Spring will assume dispatcher types of {@code FORWARD}, {@code INCLUDE} * and {@code REQUEST}, and a context pattern of "{@code /*}". * * @param hazelcastInstance Created by Spring * @return The web filter for Tomcat */ @Bean public WebFilter webFilter(HazelcastInstance hazelcastInstance) { Properties properties = new Properties(); properties.put("instance-name", hazelcastInstance.getName()); properties.put("sticky-session", "false"); return new WebFilter(properties); } }