Spring Reactive MVC vs @EnableAsync

I am new to Spring reactive modules. What I got basically basically allows reactive programming, and we can develop end-to-end reactive service.

But suppose I just want my controller to be Async, so that I can work on multiple threads and send a response like "Task Started" (not particularly this), and my work continues and closes HTTP.

I also learned about @EnableAsyncand @Asyncto create an Async method.

What if I just use the @Asynccontroller on my method that I want to make async. It worked, but is it a good practice? And can we use this in production codes?

+4
source share
1 answer

I do not see a problem when using @Async, as this will free up the flow of requests. But this is a simple approach, and it has many limitations. Please note: if you want to deal with reactive threads, you do not have an API capable of this. For example, if a method @Asynccalls another, the second will not be asynchronous.

Webflux will instead provide the most comprehensive API (in Java) to deal with in a reactive way. What you cannot do only with @Async. For example, with Flux, you can process or access multiple layers reactively, and you cannot achieve what you are doing.

, , , , , , .

, HTTP-, , , . JMS- (, ActiveMQ), .

, !

+1

Source: https://habr.com/ru/post/1691772/


All Articles