首页 > 解决方案 > springboot 应用程序需要很长时间来处理 GET 请求。DispatcherServlet.ProcessHandlerException() 花费的时间

问题描述

我有一个身份验证服务和一些控制器方法来获取基于 id、用户名等的用户详细信息。所有这些 HTTP.GET 方法都需要很长时间来处理,并且 New relic 监控显示 DispatcherServlet.ProcessHandlerException() 占了大约 70%时间。我正在使用 Spring 的 4.2.1.RELEASE 版本。任何帮助,将不胜感激。

@ApiOperation(value = "Get User Details From Id",
            notes = "Get the UserDetails object that describes the user", tags = {"/user"})
    @ApiImplicitParams({@ApiImplicitParam(dataType = "String", name = "Authorization", paramType = "header")})
    @GetMapping(value = "/users/realm/{realm}/user/{userName}", produces = Versions.V1_0)
    @Log(level = Log.Level.TRACE)
    public UserDetails getUserDetailsFromUserId(
            @ApiParam(value = "The user's details", required = true) @PathVariable(name = "realm") String realm,
            @ApiParam(value = "Include profiles in user's details") @RequestParam(name = "includeProfiles", required = false) Boolean includeProfiles,
            @PathVariable(name = "userName") String userName) {
        LOGGER.traceEntry(userName, realm, includeProfiles);
        com.nextiva.authentication.model.UserDetails result = userManagementService.getUserDetails(userName, realm, includeProfiles);
        if (includeProfiles != null && includeProfiles) {
            result.setProfiles(result.getProfiles().stream().filter(p -> NumberUtils.isDigits(p.getCorpAcctNbr()) || StringUtils.isBlank(p.getCorpAcctNbr())).collect(Collectors.toList()));
        }
        LOGGER.traceExit();
        return userDetailsConverter.convertFromModelToV1(result);
    }

示例控制器代码已附加。

标签: springspring-bootservletsnewrelic

解决方案


推荐阅读