Hi everyone. We are migrating our Grails 2 applic...
# questions
r
Hi everyone. We are migrating our Grails 2 application to Grails 4. During the migration process, we want to run both applications at the same time replicating the user session (created in the Grails 2 application) in development environment. The goal is to use both applications in combination, using the Grails 4 application as the migration process occours. The approach we are considering is to set up a cluster with embedded Tomcat, similar to the configuration in this link (Tomcat's configuration), to replicate the user session in development environment. For the Grails 4 application, we tried use Servlet API 3.0:
Copy code
class TomcatClusterConfiguration implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {

    @Override
    void customize(TomcatServletWebServerFactory factory) {
        factory.addContextCustomizers(new TomcatContextCustomizer() {

            @Override
            void customize(Context context) {
                context.setDistributable(true)

                Engine engine = ((Engine) context.getParent().getParent())
                engine.setJvmRoute("node${factory.getPort()}")

                context.setCluster(configureCluster())
            }
        })
    }
For the Grails 2 application, we used the
_Events.groovy
approach:
Copy code
// _Events.groovy
eventConfigureTomcat = { tomcat ->
    TomcatClusterConfiguration.customize(tomcat)
}
Has anyone ever needed to do something like this? Is there another way to do this?
j
I use spring-session, either redis or jdbc. Not sure how well that would work in 2 and 4, as I have only used it in 5 and 6.
j
I'm not sure how you would be able to share the same session across both versions. Spring security for example has different serial ids so they won't serialize the same betwen applications.
We also use spring-session via jdbc for sharing across nodes, but across versions is probably a step too far due to serialization being different betwen the frameworks. We've used it as early as grails 3 iirc.
j
serial ids are definitely going to be a challenge. I learned the hard way to always set it on objects stored in the session.
Copy code
class GoogleOAuth2SpringToken extends AbstractAuthenticationToken {

    private static final long serialVersionUID = 111899
}