My code: When I pass not existing email, my code returns response 200 with empty array: [] In this case I’d like to return 404 error – why the last line is not executed? A method getUserTreeGroups: And method findUserTreeGroup: I want to return to the frontend a list of TreeItem. And to be honest – I still don’t understand
Tag: spring-webflux
How to send a body with HTTP DELETE when using WebFlux?
I want to access an HTTP API which provides a DELETE endpoint. This particular endpoint expects a list of items (which I want to delete) as JSON body. Now, my problem is, I’m using Spring Webflux. But its WebClient doesn’t give me the possibility, to send a body with a DELETE request. For a POST, I’d do this: But for
Spring WebFlux and WebSocket
I am trying to add WebSocket functionality to an existing application which uses Spring WebFlux. It uses: Spring boot 2.2.1.RELEASE Tomcat container Configured to serve jsp pages When I try to connect to it through JavaScript (from inside a jsp page) I am receiving the error “failed: Error during WebSocket handshake: Unexpected response code: 404” I noted that if I
Debugging server-sent events stream from Spring in Chrome and Postman
According to the Spring documentation, when returning a Flux, Spring should emit a server-sent event for each element returned by the subscription. Here’s an exemplaric REST controller: Example response, using wget: When debugging the endpoint using Chrome or Postman, the clients seem to interpret the events as parts of a chunked response – not as a stream of events. I
What does timeout operator measure exactly for a Mono chain in Reactor and Webflux?
i’m using Spring Webflux and trying to understand the timeout concept for a chain of Monos. For example, there’s a chain of Mono calls: How is timeout going to be applied: 1) For the operations in general (sum time of operations) 2) For ech operation (each operation should take no longer than timeout) 3) Only for the last operation (nOperation)
org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type ‘text/xml;charset=UTF-8’ not supported for bodyType
using Java 11, SpringBoot 2, WebFlux, WebClient and Jackson trying to use Spring WebClient to consume a Web service endpoint that returns XML, content type: ‘text/xml;charset=UTF-8’ Jackson XML dependency in the project’s pom.xml: WebClient code that triggers a request to external API and builds the response: ServiceResponse class (a simple POJO): resulting error: org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type ‘text/xml;charset=UTF-8’ not supported for
Making multiple requests with Spring WebClient
So my goal is to use WebClient to make multiple concurrent requests, wait until they’re all completed, then combine the results. Here is what I have so far: Basically my goal is to combine all the items from each of the feeds to create one unified feed. However, I am not quite sure what to do after the call to
Mono.subscriberContext() returning old context
I have a class PublishContext with a method context() as follows : In above code, context object is Context0@744 and context1 is Context@747 which is understandable since context is immutable and always returns a new context. In my main class, I have the following code : Here, I am getting context as Context0@744, i.e Old context and hence, getting “context
Backpressure mechanism in Spring Web-Flux
I’m a starter in Spring Web-Flux. I wrote a controller as follows: I know one of the reactive benefits is Backpressure, and it can balance the request or the response rate. I want to realize how to have backpressure mechanism in Spring Web-Flux. Answer Backpressure in WebFlux In order to understand how Backpressure works in the current implementation of the
Throw an exception in a WebFilter class and handle it in a ControllerAdvice class
I’m trying to implement a WebFilter that checks a JWT and throw an exception if the check fails or the result is not valid. And I’ve a @ControllerAdvice class that handles those exceptions. But it doesn’t work. This is the WebFilter class: And the exception handler: I think, the @ControllerAdvice class can not handle exceptions that WebFilter throws. Because, if