Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use DeferredResult for asynchronous processing in SpringMVC

Shulou Source: shulou.com Published: 2022-06-01 02:08:57 09月21日 Update

This article mainly introduces how SpringMVC uses DeferredResult for asynchronous processing. The article is very detailed and has certain reference value. Interested friends must read it!

Asynchronous processing using DeferredResult

DeferredResult This class represents delayed results. DeferredResult can be used in asynchronous tasks where other threads can get DeferredResult and set the return data of DeferredResult. Asynchronous processing can usually be achieved using thread pools, queues, etc. in conjunction with DeferredResult.

According to the official description, Spring MVC processing flow is as follows:

Save DeferredResult returned by controller in memory queue or collection;

Spring MVC calls request.startAsync() to enable asynchronous;

DispatcherServlet and all Filters exit the current request thread;

The business application sets the return value of DeferredResult in the asynchronous thread, and Spring MVC sends the request again;

DispatcherServlet is called again and uses the return value of DeferredResult;

The above is "Spring MVC how to use DeferredResult asynchronous processing" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Tags: Processing thread content again article queue business representative value task interest memory official buddy partner data more process knowledge result Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Information Microsoft macOS Redmi