spring-webflux

Mock services in Spring Reactor

蹲街弑〆低调 提交于 2020-01-16 08:07:28
问题 Let's take a look over this simple method: public Mono<SuccessResponse> doSomething(){ return service1.doSomething() .then(service2.doSomething2()) .thenReturn(new SuccessResponse("Awesome"))); } So basically I want to test this method for a scenario in which, service1.doSomething() will throw an error: when(service1.doSomething()).thenReturn(Mono.error(new IllegalStateException("Something bad happened"))); when(service2.doSomething()).thenReturn(Mono.just(new SomeResponse()))

Mock services in Spring Reactor

霸气de小男生 提交于 2020-01-16 08:07:11
问题 Let's take a look over this simple method: public Mono<SuccessResponse> doSomething(){ return service1.doSomething() .then(service2.doSomething2()) .thenReturn(new SuccessResponse("Awesome"))); } So basically I want to test this method for a scenario in which, service1.doSomething() will throw an error: when(service1.doSomething()).thenReturn(Mono.error(new IllegalStateException("Something bad happened"))); when(service2.doSomething()).thenReturn(Mono.just(new SomeResponse()))

Mock services in Spring Reactor

爷,独闯天下 提交于 2020-01-16 08:07:05
问题 Let's take a look over this simple method: public Mono<SuccessResponse> doSomething(){ return service1.doSomething() .then(service2.doSomething2()) .thenReturn(new SuccessResponse("Awesome"))); } So basically I want to test this method for a scenario in which, service1.doSomething() will throw an error: when(service1.doSomething()).thenReturn(Mono.error(new IllegalStateException("Something bad happened"))); when(service2.doSomething()).thenReturn(Mono.just(new SomeResponse()))

Why does STOMP functionality in spring-websocket depend on Spring MVC?

怎甘沉沦 提交于 2020-01-13 19:42:10
问题 Currently, I am trying to use STOMP with websockets using webflux. In order to send a message to a STOMP topic, I need to use SimpMessagingTemplate , which is contributed by spring boot auto configuration when I add @EnableWebSocketMessageBroker But the problem with this is, @EnableWebSocketMessageBroker indirectly expects me to have spring-mvc library in classpath @EnableWebSocketMessageBroker @Import s DelegatingWebSocketMessageBrokerConfiguration which extends

Spring webflux bean validation not working

匆匆过客 提交于 2020-01-13 08:57:27
问题 I am trying to use bean validation in Webflux. This is what I have so far: @PostMapping("contact") fun create(@RequestBody @Valid contact: Mono<Contact>) : Mono<Contact> { return contact.flatMap { contactRepository.save(it) } .doOnError{ Error("test") } } The The validation doesn't work... I would expect that the Error("test") would be shown... Does someone has a working example(Java or Kotlin)? UPDATE Here is a repository so it can be reproducted: https://github.com/jwz104/webflux-validation

Spring webflux bean validation not working

偶尔善良 提交于 2020-01-13 08:57:05
问题 I am trying to use bean validation in Webflux. This is what I have so far: @PostMapping("contact") fun create(@RequestBody @Valid contact: Mono<Contact>) : Mono<Contact> { return contact.flatMap { contactRepository.save(it) } .doOnError{ Error("test") } } The The validation doesn't work... I would expect that the Error("test") would be shown... Does someone has a working example(Java or Kotlin)? UPDATE Here is a repository so it can be reproducted: https://github.com/jwz104/webflux-validation

Conditional repeat or retry on Mono with webclient from Spring WebFlux

爱⌒轻易说出口 提交于 2020-01-12 05:45:12
问题 What i want to do is a conditional repeat on a Mono in Webflux with webclient.The Situation is the following: We have some business rest service service that returns a generated document. the generation of this document is triggered from another service that gets called before this one. But, back to business: the document generation service needs from 10-30 seconds. What we want to do is: check after 10 seconds if document (Mono) is generated. If so, all is fine. If not, repeat (or retry)

No instance(s) of type variable(s) T exist so that Flux<T> confirms to Mono<? extend R)

痴心易碎 提交于 2020-01-06 06:34:33
问题 I am implementing Spring webflux demo application and have written my demo application as like that package com.abcplusd.application; import com.abcplusd.domain.Event; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.annotation.Bean; import org.springframework.http.MediaType; import org.springframework.web.reactive.function

Reactor Mono - execute parallel tasks

て烟熏妆下的殇ゞ 提交于 2020-01-05 10:09:22
问题 I am new to Reactor framework and trying to utilize it in one of our existing implementations. LocationProfileService and InventoryService both return a Mono and are to executed in parallel and have no dependency on each other (from the MainService). Within LocationProfileService - there are 4 queries issued and the last 2 queries have a dependency on the first query. What is a better way to write this? I see the calls getting executed sequentially, while some of them should be executed in

Why spring webflux is choosing jetty by default and then failing?

旧街凉风 提交于 2020-01-05 09:37:08
问题 I am trying to run Spring boot 2.0.0.M7 based application. Here are spring related dependencies I have in my build.gradle: compile "org.springframework.boot:spring-boot-starter-webflux:2.0.0.M7" compile "org.springframework.boot:spring-boot-starter-data-ldap:2.0.0.M7" compile "org.springframework.boot:spring-boot-starter-actuator:2.0.0.M7" Based on autoconfiguration report, is it possible to tell WHY spring wants to use Jetty as the reactive engine by default (when actually reactor Netty is