spring-webflux

Spring 5 WebFlux server push notifications via RSocket protocol

旧时模样 提交于 2020-03-23 07:55:18
问题 The case is the following: After as clients A and B established connections with a server via RSocket protocol, each of the clients could be notified with their own event(s) ( event A or event B ) to trigger some action on a client ( event X -> action on client X ). Thanks 回答1: You could achieve it with setup payload. Server: @Controller public class ServerController { private static final Map<String, RSocketRequester> REQUESTER_MAP = new HashMap<>(); @ConnectMapping("client-id") void

Reactive Spring WebClient - Making a SOAP call

余生颓废 提交于 2020-02-26 09:19:12
问题 I am looking to make a SOAP call from spring reactive webclient. I couldn't find any documentation for it. Wondering what would the approach. Right now I am thinking Construct the SOAP message using JAXB on a separate thread pool Make the call by converting it to string via webclient Do convert back into java using jaxb on the way back on separate tp. What are the downsides and any other approaches? 回答1: You need to generate SOAP client as the stub classes with methods for asynchronous. JAX

Reactive Spring WebClient - Making a SOAP call

折月煮酒 提交于 2020-02-26 09:17:05
问题 I am looking to make a SOAP call from spring reactive webclient. I couldn't find any documentation for it. Wondering what would the approach. Right now I am thinking Construct the SOAP message using JAXB on a separate thread pool Make the call by converting it to string via webclient Do convert back into java using jaxb on the way back on separate tp. What are the downsides and any other approaches? 回答1: You need to generate SOAP client as the stub classes with methods for asynchronous. JAX

WebExceptionHandler : How to write a body with Spring Webflux

寵の児 提交于 2020-02-20 07:08:30
问题 I want to handle the Exception of my api by adding a WebExceptionHandler. I can change the status code, but I am stuck when i want to change the body of the response : ex adding the exception message or a custom object. Does anyone have exemple ? How I add my WebExceptionHandler : HttpHandler httpHandler = WebHttpHandlerBuilder.webHandler(toHttpHandler(routerFunction)) .prependExceptionHandler((serverWebExchange, exception) -> { exchange.getResponse().setStatusCode(myStatusGivenTheException);

WebExceptionHandler : How to write a body with Spring Webflux

有些话、适合烂在心里 提交于 2020-02-20 07:08:11
问题 I want to handle the Exception of my api by adding a WebExceptionHandler. I can change the status code, but I am stuck when i want to change the body of the response : ex adding the exception message or a custom object. Does anyone have exemple ? How I add my WebExceptionHandler : HttpHandler httpHandler = WebHttpHandlerBuilder.webHandler(toHttpHandler(routerFunction)) .prependExceptionHandler((serverWebExchange, exception) -> { exchange.getResponse().setStatusCode(myStatusGivenTheException);

How to get username from mono<user> on spring boot webflux?

非 Y 不嫁゛ 提交于 2020-02-05 02:41:32
问题 I try to make handler and router classes of spring boot webflux. The model class is user class. Codes are @Getter @Setter @AllArgsConstructor @NoArgsConstructor @Document(collection="Users") public class User { @Id private String _id; @Indexed(unique = true) private Long id; @Indexed(unique=true) private String username; private String password; private String email; private String fullname; private String role; } And below is the handler class of webflux project. In register method, I make

In eclipse a spring boot webflux websocket application runs correctly as gradle boot run but errors as a spring boot app

送分小仙女□ 提交于 2020-01-30 10:53:52
问题 So it all runs fine from gradle bootRun as below, with the spring boot annotations hooking in configuration and control for websockets and so when I navigate to http://localhost:8082/ the mappings are properly handled with dynamic results. However, when I run exactly the same spring boot webflux app from here The http://localhost:8082/ goes to error with repeated Non-matching event type for listener: stack traces: 2020-01-28T12:22:00,073 TRACE [http-nio-8082-exec-1] org.sprin.conte.event

In eclipse a spring boot webflux websocket application runs correctly as gradle boot run but errors as a spring boot app

烈酒焚心 提交于 2020-01-30 10:48:29
问题 So it all runs fine from gradle bootRun as below, with the spring boot annotations hooking in configuration and control for websockets and so when I navigate to http://localhost:8082/ the mappings are properly handled with dynamic results. However, when I run exactly the same spring boot webflux app from here The http://localhost:8082/ goes to error with repeated Non-matching event type for listener: stack traces: 2020-01-28T12:22:00,073 TRACE [http-nio-8082-exec-1] org.sprin.conte.event

What is the best way to validate request in a Spring Webflux functional application

本小妞迷上赌 提交于 2020-01-30 04:51:52
问题 In a traditional web application it is easy to validate the request body in the controller method, eg. ResponseEntity create(@Valid @ResponseBody Post post) { } If it is a MVC application, we can gather the errors by injecting a BindingResult , and decide if there is some validation errors from the input form. In the pages, there are some helpers existed for Freemarker and Thymeleaf to display the messages. But when I come to Webflux and try to use RouterFunction to define the routing in the

How to do post-matching filter in webflux?

走远了吗. 提交于 2020-01-24 22:00:22
问题 As we know, in jersey we have pre-matching filter and post-matching filter. I'm wondering how can I get similar behavior with WebFilter in webflux application. It seems the WebFilter is sort of like a pre-matching filter which will be executed for sure, no matter a resource in @RestController found or not. My filter like this (copied from metrics filter in spring actuator): @Component @Order(100) public class AppFilter1 implements WebFilter { @Override public Mono<Void> filter