subscribe-bookmark-rate-replace
Including the basic AMPS library:
import com.crankuptheamps.client.*;
import com.crankuptheamps.client.exception.*;
Constructing the subscribe command:
Command cmd = new Command(Message.Command.Subscribe)
.setTopic(topic)
// Consistent sub id for recovery purposes and for use in replacing the subscription
.setSubId(subId)
// Start at the recovery point in the bookmark store
.setBookmark(Client.Bookmarks.MOST_RECENT)
// Set options for replay: in this case, maximum of 10,000
// messages/sec for this subscription
.setOptions(Message.Options.Rate("1000"))
;
The command can now be used in execute or executeAsync.
Construct the replace command:
Command cmd = new Command(Message.Command.Subscribe)
.setTopic(topic)
// Set ID of subscription to be replaced
.setSubId(subId)
// Set options for updated subscription: in this case, maximum of
// 100 messages/sec, and replace to update the current rate option.
.setOptions(Message.Options.Rate("100")
+ Message.Options.Replace())
;
The command can now be used in execute or execute_async to update the previous subscriptions rate option.