How can you use Spring Sessions with Redis Service in Bluemix? Is IBM Session Cache an alternative? - redis

The current app (with a competitor) is using Spring-Boot and Spring-Sessions to save session data independent from the instance in Redis.
How can we replicate this in Bluemix?
Is there a way to add on Spring-Sessions to the Redis service?
The other option would be the IBM Session Cache. Does that work with Spring-Boot and Spring-Session? Does the Session Cache service work without Tomcat? (Jetty for example?)

I haven't played with Spring-Sessions yet, but I might be able to point you in the right direction.
There is a general Redis service available on Bluemix. The open source Java buildpack (Tomcat) promises auto configuration of Redis. I would try this first. To use this buildpack:
cf push <appname> -b java_buildpack
If that doesn't work, you could read the credentials from VCAP_SERVICES and configure JedisConnectionFactory programmatically connect to it.
If you use the IBM Session Cache service with a Liberty application on Bluemix, the configuration is auto generated such that standard JEE HTTPSession objects are persisted to the service. It might work with other java runtimes, but configuration would be more manual.
Hope this helps.

Does the session cache work without Tomcat (Jetty for example)?
In general, the session cache should work with any webserver/servletcontainer, when Bluemix supports Jetty runtime for example, the session cache should support.
Session cache is based on IBM WebSphere eXtreme Scale caching technology, and the base product had been tested against WebSphere, Liberty and Tomcat runtime for the HTTP session use cases, but not tested under Jetty.

Related

Tomcat cluster with no serializable object

I have set up Tomcat cluster, behiind Apache Httpd server, with 2 nodes. I read the Tomcat documentation at Tomcat cluster how to and the first requirement is:"All your session attributes must implement java.io.Serializable". I've done and session replication, failover mechanism seems to work. Now I'm using a framework for Web app develop and it seems that the object classes that are stored in the session don't implement Serializable. I'm looking for a workaround to solve this problem in the simplier manner. I've read a lot of questions/answer but not solution so far. Any idea? Tomcat version 7.0.76. Thank you.

How to share an ignite instance among jetty webapps

The docs state:
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/startup/servlet/ServletStartup.html
Servlet-based startup may be used in any web container like Tomcat,
Jetty and etc. Depending on the way this startup is deployed the
Ignite instance can be accessed by either all web applications or by
only one. See web container class loading architecture:
But then points to a dead link regarding Jetty.
I'm using Jetty. How would this be done (sharing the ignite instance among all web applications)?
Link to Jetty classloading
Link to Ignite web configuration
The latter describes web session clustering but you don't have to enable that to use Ignite. I think these docs should cover your case.
To share Ignite instance between web apps, you will need:
Put Ignite libraries into server's main lib/ directory, and not under your web app directory
Instantiate Ignite using Jetty API, as per the documentation that you referenced
code:
Server service = new Server();
service.addListener("localhost:8090");
ServletHttpContext ctx = (ServletHttpContext)service.getContext("/");
ServletHolder servlet = ctx.addServlet("Ignite", "/IgniteStartup",
"org.apache.ignite.startup.servlet.ServletStartup");
servlet.setInitParameter("cfgFilePath", "config/default-config.xml");
servlet.setInitOrder(1);
servlet.start();
This assumes you are starting Jetty programmatically, i.e. with your own code. Your mileage may vary if you don't.

How does a GlassFish cluster find active IIOP endpoints?

I have a curiosity and I was searching for it without any result. In GlassFish documentation it is written:
If the GlassFish Server instance on which the application client is
deployed participates in a cluster, the GlassFish Server finds all
currently active IIOP endpoints in the cluster automatically. However,
a client should have at least two endpoints specified for
bootstrapping purposes, in case one of the endpoints has failed.
but I am asking myself how this list is created.
I've done some tests with a stand-alone client that is executed in a JVM and does some RMI calls on an application that is deployed in a GlassFish cluster and I can see from the logs that the IIOP endpoints list is completed automatically and it is set as com.sun.appserv.iiop.endpoints system property but if I stop a server instance or start another during the execution of the client the list remains the one that was created when the JVM was started.
GlassFish clustering is managed by the GMS (Group Management Service) which usually uses UDP Multicast, but can use TCP where that is not available.
See section 4 "Administering GlassFish Server Clusters" in the HA Administration Guide (PDF)
The Group Management Service (GMS) enables instances to participate in a cluster by
detecting changes in cluster membership and notifying instances of the changes. To
ensure that GMS can detect changes in cluster membership, a cluster's GMS settings
must be configured correctly.

Backup Spring Session with GemFire

Spring documentation says that Spring Session can transparently leverage Redis to back a web application’s HttpSession when using REST endpoints.
Does anyone know if Spring supports GemFire in this place instead of Redis to back a web application's HttpSession ?
Ref: http://docs.spring.io/spring-session/docs/current/reference/html5/guides/rest.html
Not yet, ;).
However, I did spend a little time researching the effort involved to implement a GemFire adapter for Spring Session to back (store/replicate) an HttpSession. I still need to dig a little deeper and I will be tracking this effort in JIRA here (SGF-373).
Also know that GemFire already has support for HTTP server session replication using GemFire's HTTP Session Management Module.
Will post back when I have more details.
Will these 3 steps (at a high level) be sufficient to allow Spring Session to write to Gemfire repository instead of Redis ?
Step 1: Implement just a Configuration class which provide all functions as the annotation
Allow spring to Load the configuration class
Register Spring Session Filter in Container
Establish Repo Connection Factory
Repo connection configuration
we will continue to re-use the Spring Session’s springSessionRepositoryFilter
Step 2: Need to develop an equivalent GemfireOperationsSessionRepository implementing the interface SessionRepository
Step 3: SessionMessageListener.java
3.1. Need to decide a technique to identify and save delta changes in Session to underlying repository
3.2. Need to see how session expire notification from underlying repository can be captured to invoke SessionDestroyEvent and cleanup operations -

Making Ehcache persistent with Production ReDeployment Strategy

My application that uses persistent Ehcache gets deployed as an ear file on the weblogic server. The deployment stategy used is the Production redeployment Strategy
(Production redeployment strategy involves deploying a new version of an updated application alongside an older version of the same application. WebLogic Server automatically manages client connections so that only new client requests are directed to the new version. Clients already connected to the application during the redeployment continue to use the older version of the application until they complete their work, at which point WebLogic Server automatically retires the older application.)
Since the Ehcache of the new version application is configured before the ehcache of the older version is shutdown (since the application is still running), the index and data files are not even created and used.
Hence persistence doesn't work.
What could i do to make the cache persistent? I wanted that somehow ehcahche manager stops while deploying new version in weblogic.
Regards