project-reactor

Using both publishOn and subscribeOn on a flux results in nothing happening

半腔热情 提交于 2020-01-12 08:05:32
问题 Whenever i use both subscribeOn and publishOn nothing is printed. If I use only one it will print. If I use subscribeOn(Schedulers.immediate()) or elastic it works. Any ideea why that is? It was my understanding that publishOn affects on what thread it gets published and subscribe on on what thread the subscriber runs. Could you please point me in the right direction? fun test() { val testPublisher = EmitterProcessor.create<String>().connect() testPublisher .publishOn(Schedulers.elastic())

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)

How to create a Spring Reactor Flux from Http integration flow?

蓝咒 提交于 2020-01-11 10:53:26
问题 I have a question very similar to this one How to create a Spring Reactor Flux from a ActiveMQ queue? With one difference that messages come from Http endpoint rather than JMS queue. The problem is that Message Channel is not get populated for some reason or it is not picked up by Flux.from(). The log entries show that GenericMessage is created from Http Integration flow with a payload as path variable but does not get enqueued/published to a channel? I tried .channel(MessageChannels.queue())

How to create a Spring Reactor Flux from Http integration flow?

微笑、不失礼 提交于 2020-01-11 10:53:06
问题 I have a question very similar to this one How to create a Spring Reactor Flux from a ActiveMQ queue? With one difference that messages come from Http endpoint rather than JMS queue. The problem is that Message Channel is not get populated for some reason or it is not picked up by Flux.from(). The log entries show that GenericMessage is created from Http Integration flow with a payload as path variable but does not get enqueued/published to a channel? I tried .channel(MessageChannels.queue())

How to convert List<Mono<T>> to Mono<List<T>>?

爷,独闯天下 提交于 2020-01-06 11:10:10
问题 I have a method that returns Mono<Output> : interface Processor { Mono<Output> process(Input input); } And I want to execute this processor method for a collection: List<Input> inputs = // get inputs Processor processor = // get processor List<Mono<Output>> outputs = inputs.stream().map(supplier::supply).collect(toList()); But instead of a List<Mono<Output>> I want to get Mono<List<Output>> that will contain aggregated results. I tried reduce , but the final result looks very clumsy: Mono

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

Spring webflux error handler: How to get the reactor context of the request in the error handler?

≯℡__Kan透↙ 提交于 2020-01-04 02:39:09
问题 Spring boot 2.1.5 Project Reactor 3.2.9 In my webflux project, I extensively use the reactor contexts in order to pass around some values. My purpose here is to be able to get the context inside of the Exception handler. A simple example: @Component @Order(-2) public class GlobalErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler { public GlobalErrorWebExceptionHandler(ErrorAttributes errorAttributes, ResourceProperties resourceProperties, ApplicationContext applicationContext,

Rsocket Server exception: No handler for destination '' (destination does not pass from client to server)

主宰稳场 提交于 2020-01-04 01:55:34
问题 I wrote a little demo for RSocket message The problem is that I am unable to access the Rsocket endpoint, I get the following exception from the server: The Client-side: configuration: @Bean RSocket rSocket() { return RSocketFactory.connect() .mimeType(MimeTypeUtils.APPLICATION_JSON_VALUE, MimeTypeUtils.APPLICATION_JSON_VALUE) .frameDecoder(PayloadDecoder.ZERO_COPY) .transport(TcpClientTransport.create(new InetSocketAddress(7500))) .start() .block(); } @Bean RSocketRequester requester

Nonblocking ReentrantLock with Reactor

久未见 提交于 2020-01-03 04:42:05
问题 I need to limit number of clients processing the same resource at the same time so I've tried to implement analog to lock.lock(); try { do work } finally { lock.unlock(); } but in nonblocking manner with Reactor library. And I've got something like this. But I have a question: Is there a better way to do this or maybe someone know about implemented solution or maybe this is not how it should be done in the reactive world and there is another approach for such problems? import org.slf4j.Logger

Reactive WebClient not emitting a response

时光怂恿深爱的人放手 提交于 2019-12-29 06:51:49
问题 I have a question about Spring Reactive WebClient... Few days ago I decided to play with the new reactive stuff in Spring Framework and I made one small project for scraping data only for personal purposes. (making multiple requests to one webpage and combining the results). I started using the new reactive WebClient for making requests but the problem I found is that the client not emitting response for every request. Sounds strange. Here is what I did for fetching data: private Mono<String>