/** * Verify that the specified worker task has the right type and is a version that can be handled. * * <p> * Note that whereas verifyWorkerTask() will throw an exception when there is an issue, this method will instead use the setResponse() * method on the WorkerTask and then return null.</p> */ protected final T verifyWorkerTaskAndSetResponse(final WorkerTask workerTask) { try { return verifyWorkerTask(workerTask); } catch (TaskRejectedException ex) { workerTask.setResponse(ex); return null; } catch (InvalidTaskException ex) { workerTask.setResponse(ex); return null; } }
/** * Verify that the specified worker task has the right type and is a version that can be handled. */ protected final T verifyWorkerTask(final WorkerTask workerTask) throws TaskRejectedException, InvalidTaskException { return verifyWorkerTask(workerTask.getClassifier(), workerTask.getVersion(), workerTask.getData()); }
/** * If the specified worker task is the correct type and version then the DocumentWorkerTask is de-serialised and returned. If * there is an issue with it then the appropriate response is set on the WorkerTask object and null is returned. * * @param workerTask the Worker Framework task to examine and extract the DocumentWorkerTask from * @return the decoded DocumentWorkerTask that was extracted from the WorkerTaskData object, or null if there was an error */ private AbstractTask getValidDocumentWorkerTask(final WorkerTask workerTask) { Objects.requireNonNull(workerTask); try { return application.getInputMessageProcessor().createTask(workerTask); } catch (final InvalidTaskException ex) { workerTask.setResponse(ex); return null; } catch (final TaskRejectedException ex) { workerTask.setResponse(ex); return null; } } }
bulkDocumentTask.getWorkerTask().setResponse( new TaskRejectedException("Failed to process task before scripts", ex));
bulkDocumentTask.getWorkerTask().setResponse(tre); workerTask.setResponse(workerResponse); workerTask.setResponse(new TaskRejectedException("Failed to process task after scripts", ex));