Skip to main content

subscribe-bookmark-rate-gap

Import the AMPS library:

import AMPS

Construct the command:

cmd = AMPS.Command(AMPS.Message.Command.Subscribe)
cmd.set_topic(topic)

# Set consistent ID for recovery purposes
cmd.set_sub_id(subId)

# Start at the recovery point in the bookmark store
cmd.set_bookmark(AMPS.Client.Bookmarks.MOST_RECENT)


# Set options for replay: in this case, deliver messages
# at the original rate, *except* if there is a gap
# of more than 1s in the original publish stream.
# If that happens, deliver the next message
# after a maximum of 1s.

cmd.set_options(AMPS.Message.Options.Rate('1x') + AMPS.Message.Options.RateMaxGap('1s'))

The command can now be used in execute or execute_async.