namespace pubsub = ::google::cloud::pubsub;
using ::google::cloud::Options;
[](std::string const& project_id, std::string const& topic_id) {
// This service supports specifying a regional or locational endpoint prefix
// when creating the SubscriptionAdminConnection.
// For example, to connect to "europe-central2-pubsub.googleapis.com":
auto pub = pubsub::Publisher(pubsub::MakePublisherConnection(
"europe-central2", pubsub::Topic(project_id, topic_id)));
// This configuration is common with Private Google Access:
// https://cloud.google.com/vpc/docs/private-google-access
auto vpc_pub = pubsub::Publisher(pubsub::MakePublisherConnection(
pubsub::Topic(project_id, topic_id),
Options{}.set<google::cloud::EndpointOption>(
"private.googleapis.com")));
}
Override Publisher Default Endpoint
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-03-31 UTC.

