Who maintain the session - Is it application framework or application server? - spring

I am curious, for example, when I use spring framework on tomcat server , who actually maintain the session. In other word, does spring itself have their own mechanism/logic to maintain the session, or does it delegate the session maintenance to the tomcat server?

Related

How do Tomcat Session, and Oracle Database connection interact with each other in a Java Spring web application?

I am currently working on a Spring MVC web application that is hosted on a tomcat server and is connected to an Oracle database.
I would like to know in what cicumstances does the Tomcat user session or the oracle DB connection get refresed. For example, does refreshing the webpage refresh both sessions? Does doing an ajax call refresh one or both sessions? Will doing an static action on a webpage refresh the tomcat session, and not the oracle one? In general where can one session be refeshed, but not the other?
I know this can potentally vary between configurations, but I would like a general guideline on how these interactions works.

Spring webflux session management

I am using Spring boot 2 with spring webflux running on netty.
I would like to add session management without needing to have a backing database or redis server (so Spring Session doesn't seem to be a solution here).
I could use WebSession in my controllers, but then I would need to enable sticky sessions on my load balancer, which I would prefer to avoid.
What I would like is one of the following:
Client side session like in Play framework (session is stored as a cookie and added onto each subsequent request)
Hazelcast session replication but this only works with servlet containers
Has anyone experienced the same thing and found a viable solution?
Spring Session has plans for providing Hazelcast implementation of ReactiveSessionRepository. The current plan is to wait for Hazelcast 4.0, which will move to Java 8 as baseline and use CompletableFuture instead of their own ICompletableFuture. You can track gh-831 for progress on this topic.
In the meanwhile you could try and use ReactiveMapSessionRepository, passing in Hazelcast's IMap.

Can spring boot applications deployed on a tomcat server use a common connection pooling?

When multiple spring boot applications created and deployed to a tomcat server. Is it possible to use a common connection pooling, datasource instead of providing these details in application.properties file. Or does this already taken care within the spring boot implementation
When you deploy multiple application then each application manages it connection pool.
Spring boot boundary is limited to each application context and it does not know what other application deployed and which db they are using.

Does application server provides what spring can provide

Bit confused with Spring framework and what capabilities application server provides.
I was reading this answer on same site
There he says,
Additionally App Server have components and features to support
Application level services such as Connection Pooling, Object Pooling,
Transaction Support, Messaging services etc.
That means we can optionally use apis of application server to manage transaction in our web application (inject web application :()and I think spring also provides transaction apis. So whats the difference?
Please, help me to make it clear. Thanks you.
When you use app server resources (transactions, connection pools etc.) directly in your application code, you can only run it when it is deployed on an application server or even worse only on that syme type of application server.
Spring allows you to use those resources and configure your application for different environments. The application can be run on any application server or on a simple Tomcat, or on different servers in the cloud.
Spring also allows you to run your code in tests (unit tests) without the need to start up an application server. This is absolutely needed to write automated tests.
Everything that can be done with an application server, can be done with spring as well.
There is a whole world of spring libraries and framework that provide features that are not available directly on application servers.
I can really recomand to give spring a try.....

Using of Spring Security in Cloud & autoscaling of web application

Some Web Application is managed by Spring 4.0 Framework, the Spring Security 3.2 is used also to authenticate users with remember Me feature.
The remember Me and Security is realized by JDBC Support (the needed data are saved in database).
A lot of Spring Beans is used, that are created as "spring" singletons
This Web Applicaton runs in TOMCAT7 Servlet Container, that installed in "classic" Host Sever.
This web application will be runs in production within TOMCAT7, that managed by some Cloud Provider - either in AWS Elastic Beanstalk or in EC2 Instance direct with instaled TOMCAT with autoscaling
That means, that at the first moment runs only ONE EC2 Instance, that has running TOMCAT Server 1. This server has initialized Spring Beans, holding in JVM 1.
But at "peak time" the second instance of EC2 will be started. The TOMCAT2 Server will be started also.
Is it possible, that a USER1, that was authenticated at first moment on TOMCAT1, have a problem with authentication and other business operations realized in WEb Application, if the load balancer routes the user1'Requests after start of TOMMCAT2 to TOMCAT2???
i don't know, whether Spring 4.0 or Spring Security are stateless by default.
You can consider using Elastic Load Balancer sticky sessions for your application.
Read about using Sticky Sesions here:
http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/US_StickySessions.html
Read about using Sticky Sessions with Elastic Beanstalk here:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.elb.html
Read about Stickiness policy here:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options.html

Resources