update(REQ-2516) - 适配框架中抛错的记录逻辑
This commit is contained in:
parent
9edbf2f043
commit
8a24389781
@ -40,5 +40,10 @@
|
||||
<artifactId>workflow-engine-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@ -22,12 +22,19 @@ import org.springframework.cloud.openfeign.support.ResponseEntityDecoder;
|
||||
import org.springframework.cloud.openfeign.support.SpringDecoder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.task.support.ExecutorServiceAdapter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.axzo.framework.web.exception.BasicRecordExceptionHandler.MICRO_SERVER_RECORD_ERROR_GET_PARAM_NAME;
|
||||
import static cn.axzo.framework.web.exception.BasicRecordExceptionHandler.MICRO_SERVER_RECORD_ERROR_HEADER_NAME;
|
||||
import static cn.axzo.workflow.client.config.WorkflowRequestInterceptor.HEADER_API_VERSION;
|
||||
import static cn.axzo.workflow.client.config.WorkflowRequestInterceptor.HEADER_HTTP_CLIENT;
|
||||
import static cn.axzo.workflow.client.config.WorkflowRequestInterceptor.HEADER_HTTP_CLIENT_VALUE;
|
||||
@ -80,9 +87,28 @@ public class WorkflowEngineStarterFeignConfiguration {
|
||||
//链路追踪
|
||||
template.header(Constants.CTX_LOG_ID_MDC, MDC.get(Constants.CTX_LOG_ID_MDC));
|
||||
template.header(ENABLE_MANAGEABLE, starterProperties.getManageable().toString());
|
||||
HttpServletRequest originalRequest = getOriginalRequest();
|
||||
if (Objects.nonNull(originalRequest)) {
|
||||
setRequestParams(template, originalRequest);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void setRequestParams(RequestTemplate template, HttpServletRequest originalRequest) {
|
||||
String[] packageNames = originalRequest.getParameterValues(MICRO_SERVER_RECORD_ERROR_GET_PARAM_NAME);
|
||||
template.query(MICRO_SERVER_RECORD_ERROR_GET_PARAM_NAME, packageNames);
|
||||
}
|
||||
|
||||
public HttpServletRequest getOriginalRequest() {
|
||||
try {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
return attributes.getRequest();
|
||||
} catch (Exception e) {
|
||||
log.warn("not HttpServletRequest instance bean found");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void resetInvokeMode(WorkflowEngineStarterProperties starterProperties, RequestTemplate template) {
|
||||
Collection<String> invokeModeInHeader = template.headers().getOrDefault(STARTER_INVOKE_MODE, Collections.emptyList());
|
||||
template.removeHeader(STARTER_INVOKE_MODE);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user