shaynecc / async

Asynchronous Request in Spring Web

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spring Web 异步处理

适用场景

前端发来的请求,需要处理长事务,阻塞导致超时,导致前端页面报错。

四种方式

普通阻塞

URL: 127.0.0.1:8080/blockingRequest

日志:
blockingRequest: start
wording thread
blockingRequest: end

返回: 超时返回

@Async注解

URL:127.0.0.1:8080/asyncMethod

日志:
asyncMethod: start
wording thread
asyncMethod: end

返回: 超时返回

Callable

URL:127.0.0.1:8080/callable

日志:
callable: start
callable: end
wording thread
child task thread

返回: 超时返回

DeferredResult

URL:127.0.0.1:8080/defferedResultRequest

日志:
defferedResultRequest: start
defferedResultRequest: end
wording thread

返回: 当即返回

About

Asynchronous Request in Spring Web


Languages

Language:Java 100.0%