private IndexOperationMessage handleEntityIndexUpdate(final QueueMessage message) {

    Preconditions.checkNotNull(message, "Queue Message cannot be null for handleEntityIndexUpdate");

    final AsyncEvent event = (AsyncEvent) message.getBody();

    Preconditions.checkNotNull(
        message, "QueueMessage Body cannot be null for handleEntityIndexUpdate");
    Preconditions.checkArgument(
        event instanceof EntityIndexEvent,
        String.format(
            "Event Type for handleEntityIndexUpdate must be ENTITY_INDEX, got %s",
            event.getClass()));

    final EntityIndexEvent entityIndexEvent = (EntityIndexEvent) event;

    // process the entity immediately
    // only process the same version, otherwise ignore
    final EntityIdScope entityIdScope = entityIndexEvent.getEntityIdScope();
    final ApplicationScope applicationScope = entityIdScope.getApplicationScope();
    final Id entityId = entityIdScope.getId();
    final long updatedAfter = entityIndexEvent.getUpdatedAfter();

    final EntityIndexOperation entityIndexOperation =
        new EntityIndexOperation(applicationScope, entityId, updatedAfter);

    // default this observable's return to empty index operation message if nothing is emitted
    return eventBuilder
        .buildEntityIndex(entityIndexOperation)
        .toBlocking()
        .lastOrDefault(new IndexOperationMessage());
  }
  public void index(final ApplicationScope applicationScope, final Id id, final long updatedSince) {

    EntityIndexOperation entityIndexOperation =
        new EntityIndexOperation(applicationScope, id, updatedSince);

    queueIndexOperationMessage(
        eventBuilder.buildEntityIndex(entityIndexOperation).toBlocking().lastOrDefault(null));
  }
  @Override
  public void queueEntityIndexUpdate(
      final ApplicationScope applicationScope, final Entity entity, long updatedAfter) {

    offer(
        new EntityIndexEvent(
            queueFig.getPrimaryRegion(), new EntityIdScope(applicationScope, entity.getId()), 0));

    final EntityIndexOperation entityIndexOperation =
        new EntityIndexOperation(applicationScope, entity.getId(), updatedAfter);

    final IndexOperationMessage indexMessage =
        eventBuilder.buildEntityIndex(entityIndexOperation).toBlocking().lastOrDefault(null);

    queueIndexOperationMessage(indexMessage);
  }
  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);
  }