project-reactor

Split a flux into two fluxes - head and tail

亡梦爱人 提交于 2021-02-19 02:18:37
问题 I want to split a flux into two fluxes where the first one has the first item of the original flux and the second one will takes the rest of items. After applying a custom transformation myLogic on each flux I want to combine them into one flux preserving the order of the original flux. Example: S: student S': student after applying myLogic Emitted flux: s1 -> s2 -> s3 -> s4 The first splited flux: s1' => myLogic The second splited flux: s2' -> s3' -> s4' => myLogic The combined flux: s1' ->

Split a flux into two fluxes - head and tail

社会主义新天地 提交于 2021-02-19 02:18:31
问题 I want to split a flux into two fluxes where the first one has the first item of the original flux and the second one will takes the rest of items. After applying a custom transformation myLogic on each flux I want to combine them into one flux preserving the order of the original flux. Example: S: student S': student after applying myLogic Emitted flux: s1 -> s2 -> s3 -> s4 The first splited flux: s1' => myLogic The second splited flux: s2' -> s3' -> s4' => myLogic The combined flux: s1' ->

Split a flux into two fluxes - head and tail

最后都变了- 提交于 2021-02-19 02:18:17
问题 I want to split a flux into two fluxes where the first one has the first item of the original flux and the second one will takes the rest of items. After applying a custom transformation myLogic on each flux I want to combine them into one flux preserving the order of the original flux. Example: S: student S': student after applying myLogic Emitted flux: s1 -> s2 -> s3 -> s4 The first splited flux: s1' => myLogic The second splited flux: s2' -> s3' -> s4' => myLogic The combined flux: s1' ->

Why use Circuit Breaker and Bulkhead when working with Spring Reactor?

寵の児 提交于 2021-02-17 05:34:31
问题 Please help me find reasons why Circuit breaker and Bulkhead patterns are useful in a Spring Reactor application. Since operations will be non-blocking in Reactor and those two patterns aim at saving potential hit to resources (mostly threads), in what cases can I benefit the patterns in my Spring Reactor app. The only thing I see at this point is if the requests are such a tremendously huge amount that keeping them in memory, while waiting for a timeout (instead of Circuit Breaker being up

Routing/Transforming a Mono based on content

笑着哭i 提交于 2021-02-10 19:52:29
问题 I understand this kind of breaks the idea of using project-reactor involving switching, but I am wondering if there is an appropriate way to handling this routing scenario given. Major Edit: I just went ahead and tried a more presentable implementation of the concept. Is there a significant issue with the given implementation? public interface MonoPipe<I> { public Mono<I> process(Mono<I> mono); } public static <I,P extends MonoPipe<I>> Mono<I> append(Mono<I> init, Collection<P> monoPipes){

transform vs transformDeferred

旧城冷巷雨未停 提交于 2021-02-08 10:11:10
问题 What is the difference between transform & transformDeferred in project reactor flux. Good example will be helpful. https://projectreactor.io/docs/core/release/reference/index.html#advanced-mutualizing-operator-usage 回答1: Most of the time, a Flux is "lazy": you declare a processing pipeline, but data only starts flowing once you subscribe to it. You can subscribe multiple times. This is called a cold Flux (and each time you subscribe to a cold source, the source generates its data anew for

transform vs transformDeferred

主宰稳场 提交于 2021-02-08 10:10:41
问题 What is the difference between transform & transformDeferred in project reactor flux. Good example will be helpful. https://projectreactor.io/docs/core/release/reference/index.html#advanced-mutualizing-operator-usage 回答1: Most of the time, a Flux is "lazy": you declare a processing pipeline, but data only starts flowing once you subscribe to it. You can subscribe multiple times. This is called a cold Flux (and each time you subscribe to a cold source, the source generates its data anew for

Reactive way to read and parse file from resources using WebFlux?

試著忘記壹切 提交于 2021-02-08 06:59:27
问题 I wonder what is the correct way to read, parse and serve a file from resources. Currently, I do something like this: fun getFile(request: ServerRequest): Mono<ServerResponse> { val parsedJson = objectMapper.readValue(readFile("fileName.json"), JsonModel::class.java) // modify parsed json return ok().contentType(APPLICATION_JSON).bodyValue(parsedJson) } private fun readFile(fileName: String) = DefaultResourceLoader() .getResource(fileName) .inputStream.bufferedReader().use { it.readText() } I

Using onErrorResume to handle problematic payloads posted to Kafka using Reactor Kafka

我只是一个虾纸丫 提交于 2021-02-07 19:23:40
问题 I am using reactor kafka to send in kafka messages and receive and process them. While receiving the kakfa payload, I do some deserialization, and if there is an exception, I want to just log that payload ( by saving to mongo ), and then continue receiving other payloads. For this I am using the below approach - @EventListener(ApplicationStartedEvent.class) public void kafkaReceiving() { for(Flux<ReceiverRecord<String, Object>> flux: kafkaService.getFluxReceives()) { flux.delayUntil(//some

Using onErrorResume to handle problematic payloads posted to Kafka using Reactor Kafka

安稳与你 提交于 2021-02-07 19:21:29
问题 I am using reactor kafka to send in kafka messages and receive and process them. While receiving the kakfa payload, I do some deserialization, and if there is an exception, I want to just log that payload ( by saving to mongo ), and then continue receiving other payloads. For this I am using the below approach - @EventListener(ApplicationStartedEvent.class) public void kafkaReceiving() { for(Flux<ReceiverRecord<String, Object>> flux: kafkaService.getFluxReceives()) { flux.delayUntil(//some