Exemplo n.º 1
0
  /**
   * Write the updated client pointer
   *
   * @param queueId
   * @param consumerId
   * @param lastReturnedId This is a null safe parameter. If it's null, this won't be written since
   *     it means we didn't read any messages
   */
  protected void writeClientPointer(UUID queueId, UUID consumerId, UUID lastReturnedId) {
    // nothing to do
    if (lastReturnedId == null) {
      return;
    }

    // we want to set the timestamp to the value from the time uuid. If this is
    // not the max time uuid to ever be written
    // for this consumer, we want this to be discarded to avoid internode race
    // conditions with clock drift.
    long colTimestamp = UUIDUtils.getTimestampInMicros(lastReturnedId);

    Mutator<UUID> mutator = createMutator(ko, ue);

    if (logger.isDebugEnabled()) {
      logger.debug(
          "Writing last client id pointer of '{}' for queue '{}' and consumer '{}' with timestamp '{}",
          new Object[] {lastReturnedId, queueId, consumerId, colTimestamp});
    }

    mutator.addInsertion(
        consumerId,
        CONSUMERS.getColumnFamily(),
        createColumn(queueId, lastReturnedId, colTimestamp, ue, ue));

    mutator.execute();
  }