Class ResumeTokenUtils

java.lang.Object
com.mongodb.kafka.connect.util.ResumeTokenUtils

public final class ResumeTokenUtils extends Object
  • Method Details

    • getTimestampFromResumeToken

      public static org.bson.BsonTimestamp getTimestampFromResumeToken(org.bson.BsonDocument resumeToken)
      The resume token has the following structure:
      1. It is a document with a single field named "_data" with a string value
      2. The string is hex-encoded
      3. The first byte is the "canonical type" for a BSON timestamp, encoded as an unsigned byte. It should always equal 130.
      4. The next 8 bytes are the BSON timestamp representing the operation time, encoded as an unsigned long value with big endian byte order (unlike BSON itself, which is little endian). The BsonTimestamp class contains the logic for pulling out the seconds since the epoch from that value. See http://bsonspec.org for details.
      5. There are more fields encoded in the resume token, but we don't need to decode them as operation time is always first
      Parameters:
      resumeToken - a BSonDocument containing the resume token
      Returns:
      the operation time contained within the resume token
    • parseHex

      public static byte[] parseHex(String hexString)
    • getResponseOffsetSecs

      public static OptionalLong getResponseOffsetSecs(org.bson.BsonDocument response)
      Parameters:
      response - The response from the CommandListener.
      Returns:
      The offset in seconds. The response operationTime, minus the postBatchResumeToken.