subscribe-bookmark-rate-replace
Including the basic AMPS library:
#include <amps/ampsplusplus.hpp>
Constructing the subscribe command:
AMPS::Command cmd(AMPS::Message::Command::Subscribe);
cmd.setTopic(topic);
// Set consistent subId for recovery purposes and for use in replace the subscription
cmd.setSubId(subId);
// Start from the recovery point in the bookmark store
cmd.setBookmark(AMPS::Client::MOST_RECENT());
// Set options for replay: in this case, maximum of 10,000
// messages/sec for this subscription
AMPS::Message::Options opts;
opts.setRate("1000");
cmd.setOptions(opts);
The command can now be used in execute or executeAsync.
Constructing the replace command:
AMPS::Command cmd(AMPS::Message::Command::Subscribe);
cmd.setTopic(topic);
// Set ID of subscription to be replaced
cmd.setSubId(subId);
// Set options for updated subscription: in this case, maximum of
// 100 messages/sec, and replace to update the current rate option.
AMPS::Message::Options opts;
opts.setRate("100");
opts.setReplace();
cmd.setOptions(opts);
The command can now be used in execute or executeAsync to update the previous subscriptions rate option.