Following spring webflux documentation
I couldnt but notice that every single example is based on pure websocket.
Does spring webflux supports such browser client libraries such as socket.io or sockjs?
The Spring Framework team is not considering this feature right now in WebFlux. Because of the back-pressure support in reactive streams, the team is considering protocols that would leverage that information.
For example, rsocket support would fit that space and much more. See SPR-16751
Related
I know this question has been asked a lot but i'm not able to find a CLEAR answer to my question.
The main difference i see between spring web and spring web flux is the use of Mono and Flux and ReactiveRepository. My question is : What is the difference ? (other than a syntax difference). I assume everything is different in the background but do we see these differences? Can we make something with flux that we cannot make with web mvc ?
I made a simple spring boot application using flux (playing with mono and flux) but only the syntax change, for me, i don't see any differences.
Thanks :)
Spring Reactive Gives the overview of WebFlux and Webflux is for asynchronous reactive programming & implements the Reactive Stream specification and webflux is for NIO uses cases.
In a Spring Boot (2.2.2.RELEASE) application, I have reactive endpoints (returning Mono or Flux), each of them is using reactive WebClient for calling another service. This "other" service is legacy (non-reactive) one.
Here is my question:
Is there a benefit of using Webflux (reactive WebClient) if my reactive endpoint is calling this non-reactive endpoint which does blocking stuff?
Is my reactive endpoint still reactive?
If we're talking about HTTP endpoints, we can call them with blocking or non-blocking (asynchronous) clients, but not fully reactive.
If your "new" application is reactive, you have to use non-blocking client (WebClient in your case), otherwise you will block NIO-threads and loose all the advantages of the reactive approach. The fact that the “other” application is blocking doesn't matter, you can still get a less resource-intensive "new" application.
They are
1. Not fully.
2. Your request is not full reactive until you change legacy APIs
Explanation:
End-to-End Reactive pattern only help into to the performance side
Currently you’re using reactive client this helps to connect to server in two way communication.
First set of APIs are reactive so web server layer is now reactive but data layer (Legacy APIs ) not reactive
My Spring Boot application uses a REST endpoint.
This endpoint returns a HTTP 429 (too many requests) at high load.
What is the best way to handle it?
Does Spring Boot offer possibilities here?
It depends on which version of spring you use.
If you use reactive streams (e.g. webFlux framework) then you can use backpressure mechanism.
If not, you can use for example resilience4j ratelimiter and bulkhead mechanism.
I'm developing a reactive service and preparing to use the WebClient to exchange with HTTP APIs,but the service is not in a reactive web stack so how can I use it(WebClient) without depending on Webflux or is there any alternative reactive HTTP client?
Thanks in advance.
I am not sure if I get your question correct: You want to use an inherently reactive class without the reactive lib in which it is contained?
As you can see via the link you put in your question, the WebClient is part of spring-webflux and depends e.g. on reactor.core.publisher.Mono which resides in compile("io.projectreactor:reactor-core"). I can not imagine any scenario in which this WebClient would work or make any sense as you've asked "without depending on Webflux".
Other reactive HTTP clients are:
RxHttpClient
Java HTTP Client introduced in Java 11
May be you could elaborate a little bit more on your needs, why you won't rely on WebFlux or why you want to use a reactive client in a non-reactive stack.
I want to develop a web application using websocket.
I have found two solutions for this task:
Using Spring websocket (included in Spring 4) - I am already familiarized with Spring
Using Atmosphere framework - I've read the docs, it seems to be a mature framework.
I want from the websocket framework to provide a fallback-support in case when the
browser isn't HTML5 compliant, also, I need a client-library for android.
I see that Atmosphere provides support for Socket.IO library, which I want to use on
browser client side. I see that Spring websocket provides only SockJS support over STOMP.
Can I use the same library, Socket.IO, in Spring websocket?
Do you recommend me to use Atmosphere + Spring (for building the RESTFul API) in the same
project?
Thank you
I would suggest going for the WebSocket support in Spring. If you are already using Spring, this will give you a similar programming model plus all these features:
Fallback options with SockJS
Subprotocol support with STOMP
Integration with full blown STOMP broker (like RabbitMQ)
HttpSession and WebSocket Session sync (using Spring Session)
WebSocket security (in the upcoming Spring Security 4)
SockJS Java client (for application to application communication and performance testing, haven't tried it on Android yet but might work)
Runtime Monitoring
Active community with fast response times to requests
The WebSocket support has been around since Spring 4, tested and refined for over a year now. A production ready solution which I'm using in my projects.