how to rewind a subscription cursor to a specific time in Pulsar?

Viewed 678

In the document: https://pulsar.apache.org/docs/en/concepts-clients/, it explains that you can start a consumer from earliest or latest position, or you can specify a message id. Can it support this requirement, that to specify a time point and start from there, for example, now I want to iterate the messages from yesterday 12:00 to yesterday 13:00?

1 Answers

Yes, you can rewind a subscription to a time offset. The time option of the pulsar-admin persistent reset-cursor command will do let you do this:

# bin/pulsar-admin persistent reset-cursor

    reset-cursor      Reset position for subscription to position closest to timestamp or messageId
      Usage: reset-cursor [options] persistent://tenant/namespace/topic
        Options:
          --messageId, -m
             messageId to reset back to (ledgerId:entryId)
        * -s, --subscription
             Subscription to reset position on
          --time, -t
             time in minutes to reset back to (or minutes, hours,days,weeks eg:
             100m, 3h, 2d, 5w)

You can also use the REST admin API.

Related