private IndexOperationMessage handleEdgeIndex(final QueueMessage message) { Preconditions.checkNotNull(message, "Queue Message cannot be null for handleEdgeIndex"); final AsyncEvent event = (AsyncEvent) message.getBody(); Preconditions.checkNotNull(message, "QueueMessage Body cannot be null for handleEdgeIndex"); Preconditions.checkArgument( event instanceof EdgeIndexEvent, String.format( "Event Type for handleEdgeIndex must be EDGE_INDEX, got %s", event.getClass())); final EdgeIndexEvent edgeIndexEvent = (EdgeIndexEvent) event; final EntityCollectionManager ecm = entityCollectionManagerFactory.createCollectionManager( edgeIndexEvent.getApplicationScope()); // default this observable's return to empty index operation message if nothing is emitted return ecm.load(edgeIndexEvent.getEntityId()) .flatMap( loadedEntity -> eventBuilder.buildNewEdge( edgeIndexEvent.getApplicationScope(), loadedEntity, edgeIndexEvent.getEdge())) .toBlocking() .lastOrDefault(new IndexOperationMessage()); }