@Override public void sendMessage(final TaskMessage tm) { Objects.requireNonNull(tm); // Publish this message workerCallback.send("-1", tm); }
/** * Gets the next subtask identifier, appends it to the message and publishes it. */ private void publishSubtask(final TaskMessage responseMessage) { // Do not do anything if the message is null if (responseMessage == null) { return; } // Get the next subtask identifier final int subtaskId = currentSubtaskId.incrementAndGet(); // Append the subtask id to the task id updateTaskId(responseMessage, subtaskId, false); // Add task response message to progress report buffer. progressReportBuffer.add(responseMessage); // Publish this message workerCallback.send(messageId, responseMessage); // Allow the final task to complete (in case it was blocking waiting on the message to be published) subtasksPublishedSemaphore.release(); }