use of com.yahoo.docproc.jdisc.messagebus.MbusRequestContext in project vespa by vespa-engine.
the class DocumentProcessingHandler method handleRequest.
@Override
public ContentChannel handleRequest(Request request, ResponseHandler handler) {
RequestContext requestContext;
if (request instanceof MbusRequest) {
requestContext = new MbusRequestContext((MbusRequest) request, handler, docprocServiceRegistry, docFactoryRegistry, containerDocConfig);
} else {
// Other types can be added here in the future
throw new IllegalArgumentException("Request type not supported: " + request);
}
if (!requestContext.isProcessable()) {
requestContext.skip();
return null;
}
DocprocService service = docprocServiceRegistry.getComponent(requestContext.getServiceName());
// No need to enqueue a task if the docproc chain is empty, just forward requestContext
if (service == null) {
log.log(LogLevel.ERROR, "DocprocService for session '" + requestContext.getServiceName() + "' not found, returning request '" + requestContext + "'.");
requestContext.processingFailed(RequestContext.ErrorCode.ERROR_PROCESSING_FAILURE, "DocprocService " + requestContext.getServiceName() + " not found.");
return null;
} else if (service.getExecutor().getCallStack().size() == 0) {
// call stack was empty, just forward message
requestContext.skip();
return null;
}
DocumentProcessingTask task = new DocumentProcessingTask(requestContext, this, service);
submit(task);
return null;
}
Aggregations