The maximum number of outstanding messages per streaming pull.
The Cloud Pub/Sub C++ client library uses streaming pull requests to receive messages from the service. The service will stop delivering messages if this many messages or more have neither been acknowledged nor rejected.
If a negative or 0 value is supplied, the number of messages will be unlimited.
Example
namespace pubsub = ::google::cloud::pubsub;
using ::google::cloud::future;
using ::google::cloud::Options;
using ::google::cloud::StatusOr;
auto sample = [](std::string project_id, std::string subscription_id) {
// Change the flow control watermarks, by default the client library uses
// 0 and 1,000 for the message count watermarks, and 0 and 10MiB for the
// size watermarks. Recall that the library stops requesting messages if
// any of the high watermarks are reached, and the library resumes
// requesting messages when *both* low watermarks are reached.
auto constexpr kMiB = 1024 * 1024L;
auto subscriber = pubsub::Subscriber(pubsub::MakeSubscriberConnection(
pubsub::Subscription(std::move(project_id), std::move(subscription_id)),
Options{}
.set<pubsub::MaxOutstandingMessagesOption>(1000)
.set<pubsub::MaxOutstandingBytesOption>(8 * kMiB)));
auto session = subscriber.Subscribe(
[](pubsub::Message const& m, pubsub::AckHandler h) {
std::move(h).ack();
std::cout << "Received message " << m << "\n";
PleaseIgnoreThisSimplifiesTestingTheSamples();
});
return std::make_pair(subscriber, std::move(session));
};
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["\u003cp\u003eThis webpage lists different versions of the \u003ccode\u003eMaxOutstandingMessagesOption\u003c/code\u003e for the Google Cloud Pub/Sub C++ client library, ranging from the latest release candidate 2.37.0-rc down to version 2.11.0.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eMaxOutstandingMessagesOption\u003c/code\u003e controls the maximum number of messages allowed in streaming pull requests, and the service will halt message delivery if the limit is reached, pending acknowledgments or rejections.\u003c/p\u003e\n"],["\u003cp\u003eSetting the \u003ccode\u003eMaxOutstandingMessagesOption\u003c/code\u003e to a negative or zero value will allow for an unlimited number of messages.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eMaxOutstandingMessagesOption\u003c/code\u003e type is defined as an alias of \u003ccode\u003estd::int64_t\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAn example provided shows how to set the MaxOutstandingMessagesOption to 1000, along with setting the MaxOutstandingBytesOption to 8 MiB, using the \u003ccode\u003epubsub::Subscriber\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,[]]