Jersey SubResource很慢

时间:2018-01-05 21:24:02

标签: java jersey-2.0

我无法理解为什么这个子资源占据了这么多。

问题是需要 2分钟才能从EventResource#getAttendeeSession()传递到AttendeeSessionResource#getAttendeeSessions()

看看调试模式,Stages.class专门用于lastStage.apply(continuation.result());这一纯粹的泽西岛代码的行,所以我的问题是,在这种情况下出了什么问题?< / p>

是因为它是子资源的子资源吗? (不要这么认为)

有或没有locator.inject(resource);时间相同,平均时间为110秒。

根资源

@Path("client") 
public class WebinarResource extends AbstractResource {
    @Path("{clientId}/event/{eventId}")
    public EventResource getEvent(@ApiParam(value = "", required = true) @PathParam("clientId") long clientId,
            @ApiParam(value = "", required = true) @PathParam("eventId") long eventId) throws SQLException {
        EventResource resource = new EventResource(clientId, eventId);
        locator.inject(resource);

        return resource;
    }
}

子资源

public class EventResource extends AbstractResource{

    @Path("/attendeesession")
    public AttendeeSessionResource getAttendeeSession(){
        System.out.println("EventResoure#getAttendeeSession() called: " + LocalDateTime.now());
        System.out.println("curr time milis: "+System.currentTimeMillis());
        AttendeeSessionResource resource = new AttendeeSessionResource();
        locator.inject(resource);

        return resource;
    }
}

子资源

@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public class AttendeeSessionResource extends AbstractResource{

    @PathParam("eventId") 
    private long eventId;
    //...

    @GET
    @WebinarSecurityFilter
    @WebinarThrottlingFilter(apiPrefix = "GET_EVENT_ATTENDEE_VIEWING_SESSIONS_", maxCallsPerMinute = MAX_CALLS_PER_MINUTE, endpointName = "Event-level Attendee Viewing Sessions")
    @WebinarClientValidationFilter
    @WebinarEventValidationFilter   
    public Response getAttendeeSessions(@QueryParam("sessiontype") String sessionType, @QueryParam("pageoffset") Integer pageOffset){
    System.out.println("AttendeeSessionResource#getAttendeeSessions() called: " + LocalDateTime.now());
    System.out.println("curr time milis: "+System.currentTimeMillis());     

    // THIS is the start of the resource method and it's already
    // been 110 seconds ??? why ?
    }
}

0 个答案:

没有答案