subscribe-bookmark-rate-replace
Import the AMPS library:
import AMPS
Construct the subscribe command:
cmd = AMPS.Command(AMPS.Message.Command.Subscribe)
cmd.set_topic(topic)
# Set consistent ID for recovery purposes and for use in replacing the subscription
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, maximum of 10,000
# messages/sec for this subscription
cmd.set_options(AMPS.Message.Options.Rate('1000'))
The command can now be used in execute or execute_async.
Construct the replace command:
cmd = AMPS.Command(AMPS.Message.Command.Subscribe)
cmd.set_topic(topic)
# Set ID of subscription to be replaced
cmd.set_sub_id(subId)
# Set options for updated subscription: in this case, maximum of
# 100 messages/sec, and replace to update the current rate option.
cmd.set_options(AMPS.Message.Options.Rate('100') + AMPS.Message.Options.Replace())
The command can now be used in execute or execute_async to update the previous subscriptions rate option.