public void indexBatch(final List<EdgeScope> edges, final long updatedSince) { IndexOperationMessage batch = new IndexOperationMessage(); for (EdgeScope e : edges) { EntityIndexOperation entityIndexOperation = new EntityIndexOperation( e.getApplicationScope(), e.getEdge().getTargetNode(), updatedSince); IndexOperationMessage indexOperationMessage = eventBuilder.buildEntityIndex(entityIndexOperation).toBlocking().lastOrDefault(null); if (indexOperationMessage != null) { batch.ingest(indexOperationMessage); } } queueIndexOperationMessage(batch); }
/** Submit results to index and return the queue messages to be ack'd */ private List<QueueMessage> submitToIndex(List<IndexEventResult> indexEventResults) { // if nothing came back then return empty list if (indexEventResults == null) { return new ArrayList<>(0); } IndexOperationMessage combined = new IndexOperationMessage(); List<QueueMessage> queueMessages = indexEventResults .stream() // filter out messages that are not present, they were not processed and put into the // results .filter(result -> result.getQueueMessage().isPresent()) .map( indexEventResult -> { // record the cycle time messageCycle.update( System.currentTimeMillis() - indexEventResult.getCreationTime()); // ingest each index op into our combined, single index op for the index producer if (indexEventResult.getIndexOperationMessage().isPresent()) { combined.ingest(indexEventResult.getIndexOperationMessage().get()); } return indexEventResult.getQueueMessage().get(); }) // collect into a list of QueueMessages that can be ack'd later .collect(Collectors.toList()); queueIndexOperationMessage(combined); return queueMessages; }