timeout no error
This commit is contained in:
parent
d55ae1b336
commit
122b49431c
@ -13,7 +13,6 @@ import com.pudonghot.yo.model.exception.ErrorCode;
|
||||
import com.pudonghot.yo.openapi.auth.SessionAbility;
|
||||
import com.pudonghot.yo.service.CommonAgentStatusService;
|
||||
import com.pudonghot.yo.openapi.service.AgentEventService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
@ -30,8 +29,7 @@ public class AgentEventController implements SessionAbility {
|
||||
private CommonAgentStatusService agentStatusService;
|
||||
@Autowired
|
||||
private AgentEventService agentEventService;
|
||||
@Value("${yo.server.web-async-timeout:48000}")
|
||||
private Long webAsyncTimeout;
|
||||
private final Object EMPTY = new Object();
|
||||
|
||||
@RequestMapping("/resource/agentevent/{account}")
|
||||
public DeferredResult<?> agentEvent(
|
||||
@ -44,7 +42,7 @@ public class AgentEventController implements SessionAbility {
|
||||
new Search(Agent.TENANT_ID, getTenantId())
|
||||
.eq(Agent.ACCOUNT, account));
|
||||
|
||||
val result = new DeferredResult<Object>(webAsyncTimeout);
|
||||
val result = new DeferredResult<Object>();
|
||||
|
||||
if (agent == null) {
|
||||
result.setResult(errorModel(ErrorCode.AGENT_NOT_FOUND));
|
||||
@ -78,7 +76,10 @@ public class AgentEventController implements SessionAbility {
|
||||
if (!agentEventService.fetchTempEvent(agent, result)) {
|
||||
agentEventService.put(eventKey, result);
|
||||
result.onCompletion(() -> agentEventService.remove(eventKey, result));
|
||||
result.onTimeout(() -> agentEventService.remove(eventKey, result));
|
||||
result.onTimeout(() -> {
|
||||
result.setResult(EMPTY);
|
||||
agentEventService.remove(eventKey, result);
|
||||
});
|
||||
}
|
||||
|
||||
agentEventService.updateSession(agent);
|
||||
|
@ -3,6 +3,7 @@ package com.pudonghot.yo.openapi.response;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import java.io.Serializable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.pudonghot.yo.model.agentevent.AgentEvent;
|
||||
|
||||
@ -14,6 +15,8 @@ import com.pudonghot.yo.model.agentevent.AgentEvent;
|
||||
@Getter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
public class RespAgentEvent {
|
||||
public class RespAgentEvent implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final AgentEvent event;
|
||||
}
|
||||
|
@ -55,6 +55,8 @@ dubbo:
|
||||
base-packages: com.pudonghot.yo
|
||||
|
||||
yo:
|
||||
server:
|
||||
web-async-timeout: 14600
|
||||
datasource:
|
||||
url: jdbc:mysql://172.16.4.6/yoqw?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
username: yoqw
|
||||
|
Loading…
x
Reference in New Issue
Block a user