Skip to content
Advertisement

Tag: reactive-programming

Update objects’s state in Reactor

Given the following method: switchIfEmpty and map operators mutate the profileUpdate object. Is it safe to mutate in switchIfEmpty operator? Regarding map, if I have understood correctly, this is not safe and object profileUpdate must be immutable, right? eg: Later in the chain, another method mutates the object: The above methods are called as follows: Answer Nebulous answer, but… it

How to call long running blocking void returning method with Mutiny reactive programming?

I have a chain of Async and Sync method invocation on Mutiny’s Uni, some methods are a long-running process with return type void. What is the proper way of invoking/calling them without blocking downstream? Below is the simple analogy code. Answer In general, use runSubscriptionOn and pass a specific executor: Note that it will constraint the concurrency to the number

Asynchronous Programming and Reactive Programming

This question is in my mind about a year. Actually are there any differences in Asysnchronus and Non-blocking. When we call the blocking part in our code then it becomes blocking which is synchronous and at the same time it will not be non-blocking. If we are creating another thread apart from main thread to make asynchronous programming and we

How to handle file access in a reactive environment

I’m refactoring some blocking code to reactive (using Reactor). I think most of the methods in the java.nio.file.Files class are blocking. Is it right if I replace a method like: with: I think it’s necessary, especially when cheap HDDs are used. Or does a library exists in Reactor for this kind of file manipulation? Answer Generally yes, but your code

Use case of Flux and Mono

I am new to world of Flux and Monos, and recently, while using the findAll() method, I realized that this method is capable of returning partial responses , i.e via the Flux , and I need to do append a block() if i need all the records from the CosmosDB. I was wondering what could possibly be the real world

RSocket retrieveFlux() with Kotlin

I am trying to write a client for my server (both in Kotlin and using Spring Reactive Web). I encountered this problem while trying to use the RSocket. How can I get a Flux using RSocket? Answer You need to get reference of Class. You can use either Int::class.java or Int::class depending whether you need java Class or KClass reference

Obtaining a nested objects using Spring Data R2DBC

I’m new to Project Reactor and R2DBC. How to receive and merge Flux<Child> with Mono<Parent> properly using Spring Data R2DBC reactive repositories? Parent: ParentRepository: Child: ChildRepository: ParentPersistenceAdapter: My solution is: Answer Assuming the existence of a withChildren(Flux<Child> children) type method, you can just do: However, this is a bit odd – you wouldn’t usually have a Flux on a DAO

Advertisement