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"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-21 UTC."],[[["This document outlines the `MaxOutstandingMessagesOption` for the Google Cloud Pub/Sub C++ client library, which controls the maximum number of unacknowledged messages allowed during streaming pull operations."],["The latest release is 2.37.0-rc, with a comprehensive list of previous versions extending back to 2.11.0, all of which have links to documentation regarding `MaxOutstandingMessagesOption`."],["Setting `MaxOutstandingMessagesOption` to a negative or zero value will result in unlimited messages being allowed, which affects the message flow control."],["The library stops requesting messages if the number of outstanding messages reaches the high watermark set by `MaxOutstandingMessagesOption`, and it will only resume once the low watermark is reached."],["The defined type of `MaxOutstandingMessagesOption` is a type alias of `std::int64_t`, allowing for a wide range of values to control message flow."]]],[]]