Difference between Project Reactive and Server run on Tomcat NIO Connector - spring

I'd like to write non blocking server. What is the reason to use reactive programming rather than just normal Spring MVC server run on Tomcat on NIO connector. Isn't Tomcat NIO non blocking itself?

Related

Run 2 containers in 1 spring boot application

Here're my case:
I'll use webflux starter and the default reactor netty server to serve my webflux app via 8080.
I'll use an embedded tomcat to serve my internal admin app which is servlet based, say on 7070.
Does spring boot support this by simply applying some properties settings?
I just checked:
If I have both starter-webflux and starter-tomcat, the tomcat will win at 8080.
If I change server.port = 7070, tomcat will start at 7070 and netty is still ignored.
Thanks
Leon

Spring webflux on tomcat

I just created a new application using Spring boot 2 M7 and I'm using spring-webflux.
I built the application as an autoexecutable war that I can start in dev with java -jar app.war and also on a standalone tomcat server for UAT purpose.
In the web reactive reference doc, I read
To deploy as a WAR to a Servlet 3.1+ container, wrap HttpHandler with ServletHttpHandlerAdapter and register that as a Servlet. This can be automated through the use of AbstractReactiveWebInitializer.
Baeldung site also wrote about it and they describe a procedure to register a servlet that wrap the router for a standalone environment.
Using Spring boot tomcat starter, I didn't need to do anything : no code about booting the server necessary ; the app starts using the embedded server. In debug I saw NIO access so all seems fine.
I didn't try yet but what will happen on a standalone tomcat using Spring boot tomcat starter and webflux starter ? Is spring boot take care of everything (embbeded and standalone tomcat) ? how does it work ?

Spring Boot App with WebSockets and without WebContainer

I am supposed to make an application with Spring Boot and WebSockets. But I should not use Jetty, JavaEE or Tomcat (or any other webcontainer servlet stuff). Is that even possible using "plain spring boot"???? Every example I am finding uses some kind of WebContainer. How would Spring Boot work without that to manage Http Connections and WebSocket communication?
I didnt find any working example with websockets and without a servlet. So it seems mandatory.

Spring Boot: How to configure HTTP/2 for Embedded Jetty (or Undertow)?

AFAIK Tomcat doesn't support HTTP/2 so far. Therefore, I want to use Jetty (or Undertow as another alternative), but don't know how configure the Embedded Jetty so that the ALPN JAR file can be used. Any hint is appreciated.

With Spring do you still need a java application server and when?

looks to me you need tomcat or some other servlet engine for the web part.
what about data access part using hibernate and jms? Thanks.
No, you don't need an application server, you can see Spring as a proprietary, modular application server implementation / adapter. But you still need an a servlet container.
Data access part: you can use hibernate and some standalone connection pool
jms: Spring is not a JMS provider, but it nicely integrates POJOs with any JMS provider
Spring also has comprehensive transactions support
Finally you have jmx and aop support built-in and easy integration with bean validation, jpa, web services, rmi, jci, task scheduling, caching...
As you can see you can either use certified application server and Java EE stack or built on top of Tomcat and pick Spring modules you need. Sometimes Spring uses standard Java EE APIs (like JPA), more often it builts its own.

Resources