blob: 0a48cf26b7c630bd89874fd6feae8d10d778ace5 [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Pulsar C++ client · Apache Pulsar</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta name="generator" content="Docusaurus"/><meta name="description" content="You can use Pulsar C++ client to create Pulsar producers and consumers in C++."/><meta name="docsearch:version" content="next"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="Pulsar C++ client · Apache Pulsar"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pulsar.apache.org/"/><meta property="og:description" content="You can use Pulsar C++ client to create Pulsar producers and consumers in C++."/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pulsar.apache.org/img/pulsar.svg"/><link rel="shortcut icon" href="/img/pulsar.ico"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css"/><link rel="alternate" type="application/atom+xml" href="https://pulsar.apache.org/blog/atom.xml" title="Apache Pulsar Blog ATOM Feed"/><link rel="alternate" type="application/rss+xml" href="https://pulsar.apache.org/blog/feed.xml" title="Apache Pulsar Blog RSS Feed"/><link rel="stylesheet" href="/css/code-blocks-buttons.css"/><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script><script type="text/javascript" src="/js/custom.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/en"><img class="logo" src="/img/pulsar.svg" alt="Apache Pulsar"/></a><a href="/en/versions"><h3>next</h3></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/docs/en/next/getting-started-standalone" target="_self">Docs</a></li><li class=""><a href="/en/download" target="_self">Download</a></li><li class="siteNavGroupActive"><a href="/docs/en/next/client-libraries" target="_self">Clients</a></li><li class=""><a href="#restapis" target="_self">REST APIs</a></li><li class=""><a href="#cli" target="_self">Cli</a></li><li class=""><a href="/blog/" target="_self">Blog</a></li><li class=""><a href="#community" target="_self">Community</a></li><li class=""><a href="#apache" target="_self">Apache</a></li><li class=""><a href="https://pulsar-next.staged.apache.org/" target="_self">New Website (Beta)</a></li><span><li><a id="languages-menu" href="#"><img class="languages-icon" src="/img/language.svg" alt="Languages icon"/>English</a><div id="languages-dropdown" class="hide"><ul id="languages-dropdown-items"><li><a href="/docs/ja/next/client-libraries-cpp">日本語</a></li><li><a href="/docs/fr/next/client-libraries-cpp">Français</a></li><li><a href="/docs/ko/next/client-libraries-cpp">한국어</a></li><li><a href="/docs/zh-CN/next/client-libraries-cpp">中文</a></li><li><a href="/docs/zh-TW/next/client-libraries-cpp">繁體中文</a></li><li><a href="https://crowdin.com/project/apache-pulsar" target="_blank" rel="noreferrer noopener">Help Translate</a></li></ul></div></li><script>
const languagesMenuItem = document.getElementById("languages-menu");
const languagesDropDown = document.getElementById("languages-dropdown");
languagesMenuItem.addEventListener("click", function(event) {
event.preventDefault();
if (languagesDropDown.className == "hide") {
languagesDropDown.className = "visible";
} else {
languagesDropDown.className = "hide";
}
});
</script></span></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i></i><span>Client Libraries</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Get Started</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/getting-started-standalone">Run Pulsar locally</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/getting-started-docker">Run Pulsar in Docker</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/getting-started-helm">Run Pulsar in Kubernetes</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Concepts and Architecture</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/concepts-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/concepts-messaging">Messaging</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/concepts-architecture-overview">Architecture</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/concepts-clients">Clients</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/concepts-replication">Geo Replication</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/concepts-multi-tenancy">Multi Tenancy</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/concepts-authentication">Authentication and Authorization</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/concepts-topic-compaction">Topic Compaction</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/concepts-proxy-sni-routing">Proxy support with SNI routing</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/concepts-multiple-advertised-listeners">Multiple advertised listeners</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Pulsar Schema</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/schema-get-started">Get started</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/schema-understand">Understand schema</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/schema-evolution-compatibility">Schema evolution and compatibility</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/schema-manage">Manage schema</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Pulsar Functions</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/functions-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/functions-runtime">Setup: Configure Functions runtime</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/functions-worker">Setup: Pulsar Functions Worker</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/functions-develop">How-to: Develop</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/functions-package">How-to: Package</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/functions-debug">How-to: Debug</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/functions-deploy">How-to: Deploy</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/functions-cli">Reference: CLI</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/window-functions-context">Window Functions: Context</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Pulsar IO</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/io-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/io-quickstart">Get started</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/io-use">Use</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/io-debug">Debug</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/io-connectors">Built-in connector</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/io-cdc">CDC connector</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/io-develop">Develop</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/io-cli">CLI</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Pulsar SQL</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/sql-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/sql-getting-started">Query data</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/sql-deployment-configurations">Configuration and deployment</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/sql-rest-api">REST APIs</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Tiered Storage</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/tiered-storage-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/tiered-storage-aws">AWS S3 offloader</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/tiered-storage-gcs">GCS offloader</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/tiered-storage-filesystem">Filesystem offloader</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/tiered-storage-azure">Azure BlobStore offloader</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/tiered-storage-aliyun">Aliyun OSS offloader</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Transactions</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/txn-why">Why transactions?</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/txn-what">What are transactions?</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/txn-how">How transactions work?</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/txn-use">How to use transactions?</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/txn-monitor">How to monitor transactions?</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Kubernetes (Helm)</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/helm-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/helm-prepare">Prepare</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/helm-install">Install</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/helm-deploy">Deployment</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/helm-upgrade">Upgrade</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/helm-tools">Required Tools</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Deployment</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/deploy-aws">Amazon Web Services</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/deploy-kubernetes">Kubernetes</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/deploy-bare-metal">Bare metal</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/deploy-bare-metal-multi-cluster">Bare metal multi-cluster</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/deploy-docker">Docker</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/deploy-monitoring">Monitor</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Administration</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/administration-zk-bk">ZooKeeper and BookKeeper</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/administration-geo">Geo-replication</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/administration-pulsar-manager">Pulsar Manager</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/administration-stats">Pulsar statistics</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/administration-load-balance">Load balance</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/administration-proxy">Pulsar proxy</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/administration-upgrade">Upgrade</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/administration-isolation">Pulsar isolation</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Security</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/security-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/security-policy-and-supported-versions">Security Policy and Supported Versions</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/security-tls-transport">Transport Encryption using TLS</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/security-tls-authentication">Authentication using TLS</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/security-tls-keystore">Using TLS with KeyStore configure</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/security-jwt">Authentication using JWT</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/security-athenz">Authentication using Athenz</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/security-kerberos">Authentication using Kerberos</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/security-oauth2">Authentication using OAuth 2.0 access tokens</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/security-authorization">Authorization and ACLs</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/security-encryption">End-to-End Encryption</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/security-extending">Extend Authentication and Authorization</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/security-bouncy-castle">Bouncy Castle Providers</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Performance</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/performance-pulsar-perf">Pulsar Perf</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Client Libraries</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/client-libraries">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/client-libraries-java">Java</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/client-libraries-go">Go</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/client-libraries-python">Python</a></li><li class="navListItem navListItemActive"><a class="navItem" href="/docs/en/next/client-libraries-cpp">C++</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/client-libraries-node">Node.js</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/client-libraries-websocket">WebSocket</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/client-libraries-dotnet">C#</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/client-libraries-rest">REST</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Admin API</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/admin-api-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/admin-api-clusters">Clusters</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/admin-api-tenants">Tenants</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/admin-api-brokers">Brokers</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/admin-api-namespaces">Namespaces</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/admin-api-permissions">Permissions</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/admin-api-topics">Topics</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/admin-api-functions">Functions</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/admin-api-packages">Packages</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Adaptors</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/adaptors-kafka">Kafka client wrapper</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/adaptors-spark">Apache Spark</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/adaptors-storm">Apache Storm</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Cookbooks</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/cookbooks-compaction">Topic compaction</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/cookbooks-deduplication">Message deduplication</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/cookbooks-non-persistent">Non-persistent messaging</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/cookbooks-retention-expiry">Message retention and expiry</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/cookbooks-encryption">Encryption</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/cookbooks-message-queue">Message queue</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/cookbooks-bookkeepermetadata">BookKeeper Ledger Metadata</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Development</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/develop-tools">Simulation tools</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/developing-binary-protocol">Binary protocol</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/develop-load-manager">Modular load manager</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/develop-plugin">Plugin</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Reference</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/next/reference-terminology">Terminology</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/reference-cli-tools">Pulsar CLI tools</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/reference-configuration">Pulsar configuration</a></li><li class="navListItem"><a class="navItem" href="/docs/en/next/reference-metrics">Pulsar Metrics</a></li></ul></div></div></section></div><script>
var coll = document.getElementsByClassName('collapsible');
var checkActiveCategory = true;
for (var i = 0; i < coll.length; i++) {
var links = coll[i].nextElementSibling.getElementsByTagName('*');
if (checkActiveCategory){
for (var j = 0; j < links.length; j++) {
if (links[j].classList.contains('navListItemActive')){
coll[i].nextElementSibling.classList.toggle('hide');
coll[i].childNodes[1].classList.toggle('rotate');
checkActiveCategory = false;
break;
}
}
}
coll[i].addEventListener('click', function() {
var arrow = this.childNodes[1];
arrow.classList.toggle('rotate');
var content = this.nextElementSibling;
content.classList.toggle('hide');
});
}
document.addEventListener('DOMContentLoaded', function() {
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
createToggler('#tocToggler', 'body', 'tocActive');
var headings = document.querySelector('.toc-headings');
headings && headings.addEventListener('click', function(event) {
var el = event.target;
while(el !== headings){
if (el.tagName === 'A') {
document.body.classList.remove('tocActive');
break;
} else{
el = el.parentNode;
}
}
}, false);
function createToggler(togglerSelector, targetSelector, className) {
var toggler = document.querySelector(togglerSelector);
var target = document.querySelector(targetSelector);
if (!toggler) {
return;
}
toggler.onclick = function(event) {
event.preventDefault();
target.classList.toggle(className);
};
}
});
</script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"><a class="edit-page-link button" href="https://github.com/apache/pulsar/edit/master/site2/docs/client-libraries-cpp.md" target="_blank" rel="noreferrer noopener">Edit</a><h1 id="__docusaurus" class="postHeaderTitle">Pulsar C++ client</h1></header><article><div><span><p>You can use Pulsar C++ client to create Pulsar producers and consumers in C++.</p>
<p>All the methods in producer, consumer, and reader of a C++ client are thread-safe.</p>
<h2><a class="anchor" aria-hidden="true" id="supported-platforms"></a><a href="#supported-platforms" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Supported platforms</h2>
<p>Pulsar C++ client is supported on <strong>Linux</strong> ,<strong>MacOS</strong> and <strong>Windows</strong> platforms.</p>
<p><a href="http://www.doxygen.nl/">Doxygen</a>-generated API docs for the C++ client are available <a href="/api/cpp/2.10.0-SNAPSHOT">here</a>.</p>
<h2><a class="anchor" aria-hidden="true" id="linux"></a><a href="#linux" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Linux</h2>
<blockquote>
<p><strong>Note</strong> <br>
You can choose one of the following installation methods based on your needs: Compilation, Install RPM or Install Debian.</p>
</blockquote>
<h3><a class="anchor" aria-hidden="true" id="compilation"></a><a href="#compilation" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Compilation</h3>
<h4><a class="anchor" aria-hidden="true" id="system-requirements"></a><a href="#system-requirements" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>System requirements</h4>
<p>You need to install the following components before using the C++ client:</p>
<ul>
<li><a href="https://cmake.org/">CMake</a></li>
<li><a href="http://www.boost.org/">Boost</a></li>
<li><a href="https://developers.google.com/protocol-buffers/">Protocol Buffers</a> &gt;= 3</li>
<li><a href="https://curl.se/libcurl/">libcurl</a></li>
<li><a href="https://github.com/google/googletest">Google Test</a></li>
</ul>
<ol>
<li>Clone the Pulsar repository.</li>
</ol>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> git <span class="hljs-built_in">clone</span> https://github.com/apache/pulsar</span>
</code></pre>
<ol start="2">
<li>Install all necessary dependencies.</li>
</ol>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> apt-get install cmake libssl-dev libcurl4-openssl-dev liblog4cxx-dev \</span>
libprotobuf-dev protobuf-compiler libboost-all-dev google-mock libgtest-dev libjsoncpp-dev
</code></pre>
<ol start="3">
<li>Compile and install <a href="https://github.com/google/googletest">Google Test</a>.</li>
</ol>
<pre><code class="hljs css language-shell"><span class="hljs-meta">#</span><span class="bash"> libgtest-dev version is 1.18.0 or above</span>
<span class="hljs-meta">$</span><span class="bash"> <span class="hljs-built_in">cd</span> /usr/src/googletest</span>
<span class="hljs-meta">$</span><span class="bash"> sudo cmake .</span>
<span class="hljs-meta">$</span><span class="bash"> sudo make</span>
<span class="hljs-meta">$</span><span class="bash"> sudo cp ./googlemock/libgmock.a ./googlemock/gtest/libgtest.a /usr/lib/</span>
<span class="hljs-meta">
#</span><span class="bash"> less than 1.18.0</span>
<span class="hljs-meta">$</span><span class="bash"> <span class="hljs-built_in">cd</span> /usr/src/gtest</span>
<span class="hljs-meta">$</span><span class="bash"> sudo cmake .</span>
<span class="hljs-meta">$</span><span class="bash"> sudo make</span>
<span class="hljs-meta">$</span><span class="bash"> sudo cp libgtest.a /usr/lib</span>
<span class="hljs-meta">
$</span><span class="bash"> <span class="hljs-built_in">cd</span> /usr/src/gmock</span>
<span class="hljs-meta">$</span><span class="bash"> sudo cmake .</span>
<span class="hljs-meta">$</span><span class="bash"> sudo make</span>
<span class="hljs-meta">$</span><span class="bash"> sudo cp libgmock.a /usr/lib</span>
</code></pre>
<ol start="4">
<li>Compile the Pulsar client library for C++ inside the Pulsar repository.</li>
</ol>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> <span class="hljs-built_in">cd</span> pulsar-client-cpp</span>
<span class="hljs-meta">$</span><span class="bash"> cmake .</span>
<span class="hljs-meta">$</span><span class="bash"> make</span>
</code></pre>
<p>After you install the components successfully, the files <code>libpulsar.so</code> and <code>libpulsar.a</code> are in the <code>lib</code> folder of the repository. The tools <code>perfProducer</code> and <code>perfConsumer</code> are in the <code>perf</code> directory.</p>
<h3><a class="anchor" aria-hidden="true" id="install-dependencies"></a><a href="#install-dependencies" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Install Dependencies</h3>
<blockquote>
<p>Since 2.1.0 release, Pulsar ships pre-built RPM and Debian packages. You can download and install those packages directly.</p>
</blockquote>
<p>After you download and install RPM or DEB, the <code>libpulsar.so</code>, <code>libpulsarnossl.so</code>, <code>libpulsar.a</code>, and <code>libpulsarwithdeps.a</code> libraries are in your <code>/usr/lib</code> directory.</p>
<p>By default, they are built in code path <code>${PULSAR_HOME}/pulsar-client-cpp</code>. You can build with the command below.</p>
<p><code>cmake . -DBUILD_TESTS=OFF -DLINK_STATIC=ON &amp;&amp; make pulsarShared pulsarSharedNossl pulsarStatic pulsarStaticWithDeps -j 3</code>.</p>
<p>These libraries rely on some other libraries. If you want to get detailed version of dependencies, see <a href="https://github.com/apache/pulsar/blob/master/pulsar-client-cpp/pkg/rpm/Dockerfile">RPM</a> or <a href="https://github.com/apache/pulsar/blob/master/pulsar-client-cpp/pkg/deb/Dockerfile">DEB</a> files.</p>
<ol>
<li><code>libpulsar.so</code> is a shared library, containing statically linked <code>boost</code> and <code>openssl</code>. It also dynamically links all other necessary libraries. You can use this Pulsar library with the command below.</li>
</ol>
<pre><code class="hljs css language-bash"> g++ --std=c++11 PulsarTest.cpp -o <span class="hljs-built_in">test</span> /usr/lib/libpulsar.so -I/usr/<span class="hljs-built_in">local</span>/ssl/include
</code></pre>
<ol start="2">
<li><code>libpulsarnossl.so</code> is a shared library, similar to <code>libpulsar.so</code> except that the libraries <code>openssl</code> and <code>crypto</code> are dynamically linked. You can use this Pulsar library with the command below.</li>
</ol>
<pre><code class="hljs css language-bash"> g++ --std=c++11 PulsarTest.cpp -o <span class="hljs-built_in">test</span> /usr/lib/libpulsarnossl.so -lssl -lcrypto -I/usr/<span class="hljs-built_in">local</span>/ssl/include -L/usr/<span class="hljs-built_in">local</span>/ssl/lib
</code></pre>
<ol start="3">
<li><code>libpulsar.a</code> is a static library. You need to load dependencies before using this library. You can use this Pulsar library with the command below.</li>
</ol>
<pre><code class="hljs css language-bash"> g++ --std=c++11 PulsarTest.cpp -o <span class="hljs-built_in">test</span> /usr/lib/libpulsar.a -lssl -lcrypto -ldl -lpthread -I/usr/<span class="hljs-built_in">local</span>/ssl/include -L/usr/<span class="hljs-built_in">local</span>/ssl/lib -lboost_system -lboost_regex -lcurl -lprotobuf -lzstd -lz
</code></pre>
<ol start="4">
<li><code>libpulsarwithdeps.a</code> is a static library, based on <code>libpulsar.a</code>. It is archived in the dependencies of <code>libboost_regex</code>, <code>libboost_system</code>, <code>libcurl</code>, <code>libprotobuf</code>, <code>libzstd</code> and <code>libz</code>. You can use this Pulsar library with the command below.</li>
</ol>
<pre><code class="hljs css language-bash"> g++ --std=c++11 PulsarTest.cpp -o <span class="hljs-built_in">test</span> /usr/lib/libpulsarwithdeps.a -lssl -lcrypto -ldl -lpthread -I/usr/<span class="hljs-built_in">local</span>/ssl/include -L/usr/<span class="hljs-built_in">local</span>/ssl/lib
</code></pre>
<p>The <code>libpulsarwithdeps.a</code> does not include library openssl related libraries <code>libssl</code> and <code>libcrypto</code>, because these two libraries are related to security. It is more reasonable and easier to use the versions provided by the local system to handle security issues and upgrade libraries.</p>
<h3><a class="anchor" aria-hidden="true" id="install-rpm"></a><a href="#install-rpm" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Install RPM</h3>
<ol>
<li>Download a RPM package from the links in the table.</li>
</ol>
<table>
<thead>
<tr><th>Link</th><th>Crypto files</th></tr>
</thead>
<tbody>
<tr><td><a href="https://archive.apache.org/dist/pulsar/pulsar-2.10.0/RPMS/apache-pulsar-client-2.10.0-1.x86_64.rpm">client</a></td><td><a href="https://archive.apache.org/dist/pulsar/pulsar-2.10.0/RPMS/apache-pulsar-client-2.10.0-1.x86_64.rpm.asc">asc</a>, <a href="https://archive.apache.org/dist/pulsar/pulsar-2.10.0/RPMS/apache-pulsar-client-2.10.0-1.x86_64.rpm.sha512">sha512</a></td></tr>
<tr><td><a href="https://archive.apache.org/dist/pulsar/pulsar-2.10.0/RPMS/apache-pulsar-client-debuginfo-2.10.0-1.x86_64.rpm">client-debuginfo</a></td><td><a href="https://archive.apache.org/dist/pulsar/pulsar-2.10.0/RPMS/apache-pulsar-client-debuginfo-2.10.0-1.x86_64.rpm.asc">asc</a>, <a href="https://archive.apache.org/dist/pulsar/pulsar-2.10.0/RPMS/apache-pulsar-client-debuginfo-2.10.0-1.x86_64.rpm.sha512">sha512</a></td></tr>
<tr><td><a href="https://archive.apache.org/dist/pulsar/pulsar-2.10.0/RPMS/apache-pulsar-client-devel-2.10.0-1.x86_64.rpm">client-devel</a></td><td><a href="https://archive.apache.org/dist/pulsar/pulsar-2.10.0/RPMS/apache-pulsar-client-devel-2.10.0-1.x86_64.rpm.asc">asc</a>, <a href="https://archive.apache.org/dist/pulsar/pulsar-2.10.0/RPMS/apache-pulsar-client-devel-2.10.0-1.x86_64.rpm.sha512">sha512</a></td></tr>
</tbody>
</table>
<ol start="2">
<li>Install the package using the following command.</li>
</ol>
<pre><code class="hljs css language-bash">$ rpm -ivh apache-pulsar-client*.rpm
</code></pre>
<p>After you install RPM successfully, Pulsar libraries are in the <code>/usr/lib</code> directory, for example:</p>
<pre><code class="hljs css language-bash">lrwxrwxrwx 1 root root 18 Dec 30 22:21 libpulsar.so -&gt; libpulsar.so.2.9.1
lrwxrwxrwx 1 root root 23 Dec 30 22:21 libpulsarnossl.so -&gt; libpulsarnossl.so.2.9.1
</code></pre>
<blockquote>
<p><strong>Note</strong> <br>
If you get the error that <code>libpulsar.so: cannot open shared object file: No such file or directory</code> when starting Pulsar client, you may need to run <code>ldconfig</code> first.</p>
</blockquote>
<ol start="2">
<li>Install the GCC and g++ using the following command, otherwise errors would occur in installing Node.js.</li>
</ol>
<pre><code class="hljs css language-bash">$ sudo yum -y install gcc automake autoconf libtool make
$ sudo yum -y install gcc-c++
</code></pre>
<h3><a class="anchor" aria-hidden="true" id="install-debian"></a><a href="#install-debian" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Install Debian</h3>
<ol>
<li>Download a Debian package from the links in the table.</li>
</ol>
<table>
<thead>
<tr><th>Link</th><th>Crypto files</th></tr>
</thead>
<tbody>
<tr><td><a href="https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=pulsar/pulsar-2.10.0/DEB/apache-pulsar-client.deb">client</a></td><td><a href="https://archive.apache.org/dist/pulsar/pulsar-2.10.0/DEB/apache-pulsar-client.deb.asc">asc</a>, <a href="https://archive.apache.org/dist/pulsar/pulsar-2.10.0/DEB/apache-pulsar-client.deb.sha512">sha512</a></td></tr>
<tr><td><a href="https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=pulsar/pulsar-2.10.0/DEB/apache-pulsar-client-dev.deb">client-devel</a></td><td><a href="https://archive.apache.org/dist/pulsar/pulsar-2.10.0/DEB/apache-pulsar-client-dev.deb.asc">asc</a>, <a href="https://archive.apache.org/dist/pulsar/pulsar-2.10.0/DEB/apache-pulsar-client-dev.deb.sha512">sha512</a></td></tr>
</tbody>
</table>
<ol start="2">
<li>Install the package using the following command.</li>
</ol>
<pre><code class="hljs css language-bash">$ apt install ./apache-pulsar-client*.deb
</code></pre>
<p>After you install DEB successfully, Pulsar libraries are in the <code>/usr/lib</code> directory.</p>
<h3><a class="anchor" aria-hidden="true" id="build"></a><a href="#build" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Build</h3>
<blockquote>
<p>If you want to build RPM and Debian packages from the latest master, follow the instructions below. You should run all the instructions at the root directory of your cloned Pulsar repository.</p>
</blockquote>
<p>There are recipes that build RPM and Debian packages containing a
statically linked <code>libpulsar.so</code> / <code>libpulsarnossl.so</code> / <code>libpulsar.a</code> / <code>libpulsarwithdeps.a</code> with all required dependencies.</p>
<p>To build the C++ library packages, you need to build the Java packages first.</p>
<pre><code class="hljs css language-shell">mvn install -DskipTests
</code></pre>
<h4><a class="anchor" aria-hidden="true" id="rpm"></a><a href="#rpm" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>RPM</h4>
<p>To build the RPM inside a Docker container, use the command below. The RPMs are in the <code>pulsar-client-cpp/pkg/rpm/RPMS/x86_64/</code> path.</p>
<pre><code class="hljs css language-shell">pulsar-client-cpp/pkg/rpm/docker-build-rpm.sh
</code></pre>
<table>
<thead>
<tr><th>Package name</th><th>Content</th></tr>
</thead>
<tbody>
<tr><td>pulsar-client</td><td>Shared library <code>libpulsar.so</code> and <code>libpulsarnossl.so</code></td></tr>
<tr><td>pulsar-client-devel</td><td>Static library <code>libpulsar.a</code>, <code>libpulsarwithdeps.a</code>and C++ and C headers</td></tr>
<tr><td>pulsar-client-debuginfo</td><td>Debug symbols for <code>libpulsar.so</code></td></tr>
</tbody>
</table>
<h4><a class="anchor" aria-hidden="true" id="debian"></a><a href="#debian" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Debian</h4>
<p>To build Debian packages, enter the following command.</p>
<pre><code class="hljs css language-shell">pulsar-client-cpp/pkg/deb/docker-build-deb.sh
</code></pre>
<p>Debian packages are created in the <code>pulsar-client-cpp/pkg/deb/BUILD/DEB/</code> path.</p>
<table>
<thead>
<tr><th>Package name</th><th>Content</th></tr>
</thead>
<tbody>
<tr><td>pulsar-client</td><td>Shared library <code>libpulsar.so</code> and <code>libpulsarnossl.so</code></td></tr>
<tr><td>pulsar-client-dev</td><td>Static library <code>libpulsar.a</code>, <code>libpulsarwithdeps.a</code> and C++ and C headers</td></tr>
</tbody>
</table>
<h2><a class="anchor" aria-hidden="true" id="macos"></a><a href="#macos" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>MacOS</h2>
<h3><a class="anchor" aria-hidden="true" id="compilation-1"></a><a href="#compilation-1" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Compilation</h3>
<ol>
<li>Clone the Pulsar repository.</li>
</ol>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> git <span class="hljs-built_in">clone</span> https://github.com/apache/pulsar</span>
</code></pre>
<ol start="2">
<li>Install all necessary dependencies.</li>
</ol>
<pre><code class="hljs css language-shell"><span class="hljs-meta">#</span><span class="bash"> OpenSSL installation</span>
<span class="hljs-meta">$</span><span class="bash"> brew install openssl</span>
<span class="hljs-meta">$</span><span class="bash"> <span class="hljs-built_in">export</span> OPENSSL_INCLUDE_DIR=/usr/<span class="hljs-built_in">local</span>/opt/openssl/include/</span>
<span class="hljs-meta">$</span><span class="bash"> <span class="hljs-built_in">export</span> OPENSSL_ROOT_DIR=/usr/<span class="hljs-built_in">local</span>/opt/openssl/</span>
<span class="hljs-meta">
#</span><span class="bash"> Protocol Buffers installation</span>
<span class="hljs-meta">$</span><span class="bash"> brew install protobuf boost boost-python log4cxx</span>
<span class="hljs-meta">#</span><span class="bash"> If you are using python3, you need to install boost-python3 </span>
<span class="hljs-meta">
#</span><span class="bash"> Google Test installation</span>
<span class="hljs-meta">$</span><span class="bash"> git <span class="hljs-built_in">clone</span> https://github.com/google/googletest.git</span>
<span class="hljs-meta">$</span><span class="bash"> <span class="hljs-built_in">cd</span> googletest</span>
<span class="hljs-meta">$</span><span class="bash"> cmake .</span>
<span class="hljs-meta">$</span><span class="bash"> make install</span>
</code></pre>
<ol start="3">
<li>Compile the Pulsar client library in the repository that you cloned.</li>
</ol>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> <span class="hljs-built_in">cd</span> pulsar-client-cpp</span>
<span class="hljs-meta">$</span><span class="bash"> cmake .</span>
<span class="hljs-meta">$</span><span class="bash"> make</span>
</code></pre>
<h3><a class="anchor" aria-hidden="true" id="install-libpulsar"></a><a href="#install-libpulsar" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Install <code>libpulsar</code></h3>
<p>Pulsar releases are available in the <a href="https://brew.sh/">Homebrew</a> core repository. You can install the C++ client library with the following command. The package is installed with the library and headers.</p>
<pre><code class="hljs css language-shell">brew install libpulsar
</code></pre>
<h2><a class="anchor" aria-hidden="true" id="windows-64-bit"></a><a href="#windows-64-bit" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Windows (64-bit)</h2>
<h3><a class="anchor" aria-hidden="true" id="compilation-2"></a><a href="#compilation-2" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Compilation</h3>
<ol>
<li>Clone the Pulsar repository.</li>
</ol>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> git <span class="hljs-built_in">clone</span> https://github.com/apache/pulsar</span>
</code></pre>
<ol start="2">
<li>Install all necessary dependencies.</li>
</ol>
<pre><code class="hljs css language-shell">cd ${PULSAR_HOME}/pulsar-client-cpp
vcpkg install --feature-flags=manifests --triplet x64-windows
</code></pre>
<ol start="3">
<li>Build C++ libraries.</li>
</ol>
<pre><code class="hljs css language-shell">cmake -B ./build -A x64 -DBUILD_PYTHON_WRAPPER=OFF -DBUILD_TESTS=OFF -DVCPKG_TRIPLET=x64-windows -DCMAKE_BUILD_TYPE=Release -S .
cmake --build ./build --config Release
</code></pre>
<blockquote>
<p><strong>NOTE</strong></p>
<ol>
<li>For Windows 32-bit, you need to use <code>-A Win32</code> and <code>-DVCPKG_TRIPLET=x86-windows</code>.</li>
<li>For MSVC Debug mode, you need to replace <code>Release</code> with <code>Debug</code> for both <code>CMAKE_BUILD_TYPE</code> variable and <code>--config</code> option.</li>
</ol>
</blockquote>
<ol start="4">
<li>Client libraries are available in the following places.</li>
</ol>
<pre><code class="hljs">${PULSAR_HOME}/pulsar-client-cpp/build/<span class="hljs-class"><span class="hljs-keyword">lib</span>/<span class="hljs-title">Release</span>/<span class="hljs-title">pulsar</span>.<span class="hljs-title">lib</span></span>
${PULSAR_HOME}/pulsar-client-cpp/build/<span class="hljs-class"><span class="hljs-keyword">lib</span>/<span class="hljs-title">Release</span>/<span class="hljs-title">pulsar</span>.<span class="hljs-title">dll</span></span>
</code></pre>
<h2><a class="anchor" aria-hidden="true" id="connection-urls"></a><a href="#connection-urls" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Connection URLs</h2>
<p>To connect Pulsar using client libraries, you need to specify a Pulsar protocol URL.</p>
<p>Pulsar protocol URLs are assigned to specific clusters, you can use the Pulsar URI scheme. The default port is <code>6650</code>. The following is an example for localhost.</p>
<pre><code class="hljs css language-http">pulsar://localhost:6650
</code></pre>
<p>In a Pulsar cluster in production, the URL looks as follows.</p>
<pre><code class="hljs css language-http">pulsar://pulsar.us-west.example.com:6650
</code></pre>
<p>If you use TLS authentication, you need to add <code>ssl</code>, and the default port is <code>6651</code>. The following is an example.</p>
<pre><code class="hljs css language-http">pulsar+ssl://pulsar.us-west.example.com:6651
</code></pre>
<h2><a class="anchor" aria-hidden="true" id="create-a-producer"></a><a href="#create-a-producer" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Create a producer</h2>
<p>To use Pulsar as a producer, you need to create a producer on the C++ client. There are two main ways of using a producer:</p>
<ul>
<li><a href="#simple-blocking-example">Blocking style</a> : each call to <code>send</code> waits for an ack from the broker.</li>
<li><a href="#non-blocking-example">Non-blocking asynchronous style</a> : <code>sendAsync</code> is called instead of <code>send</code> and a callback is supplied for when the ack is received from the broker.</li>
</ul>
<h3><a class="anchor" aria-hidden="true" id="simple-blocking-example"></a><a href="#simple-blocking-example" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Simple blocking example</h3>
<p>This example sends 100 messages using the blocking style. While simple, it does not produce high throughput as it waits for each ack to come back before sending the next message.</p>
<pre><code class="hljs css language-c++"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;pulsar/Client.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;thread&gt;</span></span>
<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> pulsar;
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> </span>{
<span class="hljs-function"><span class="hljs-built_in">Client</span> <span class="hljs-title">client</span><span class="hljs-params">(<span class="hljs-string">"pulsar://localhost:6650"</span>)</span></span>;
Producer producer;
Result result = client.createProducer(<span class="hljs-string">"persistent://public/default/my-topic"</span>, producer);
<span class="hljs-keyword">if</span> (result != ResultOk) {
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Error creating producer: "</span> &lt;&lt; result &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
<span class="hljs-keyword">return</span> <span class="hljs-number">-1</span>;
}
<span class="hljs-comment">// Send 100 messages synchronously</span>
<span class="hljs-keyword">int</span> ctr = <span class="hljs-number">0</span>;
<span class="hljs-keyword">while</span> (ctr &lt; <span class="hljs-number">100</span>) {
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> content = <span class="hljs-string">"msg"</span> + <span class="hljs-built_in">std</span>::to_string(ctr);
Message msg = MessageBuilder().setContent(content).setProperty(<span class="hljs-string">"x"</span>, <span class="hljs-string">"1"</span>).build();
Result result = producer.send(msg);
<span class="hljs-keyword">if</span> (result != ResultOk) {
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"The message "</span> &lt;&lt; content &lt;&lt; <span class="hljs-string">" could not be sent, received code: "</span> &lt;&lt; result &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
} <span class="hljs-keyword">else</span> {
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"The message "</span> &lt;&lt; content &lt;&lt; <span class="hljs-string">" sent successfully"</span> &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
}
<span class="hljs-built_in">std</span>::this_thread::sleep_for(<span class="hljs-built_in">std</span>::chrono::milliseconds(<span class="hljs-number">100</span>));
ctr++;
}
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Finished producing synchronously!"</span> &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
client.<span class="hljs-built_in">close</span>();
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<h3><a class="anchor" aria-hidden="true" id="non-blocking-example"></a><a href="#non-blocking-example" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Non-blocking example</h3>
<p>This example sends 100 messages using the non-blocking style calling <code>sendAsync</code> instead of <code>send</code>. This allows the producer to have multiple messages inflight at a time which increases throughput.</p>
<p>The producer configuration <code>blockIfQueueFull</code> is useful here to avoid <code>ResultProducerQueueIsFull</code> errors when the internal queue for outgoing send requests becomes full. Once the internal queue is full, <code>sendAsync</code> becomes blocking which can make your code simpler.</p>
<p>Without this configuration, the result code <code>ResultProducerQueueIsFull</code> is passed to the callback. You must decide how to deal with that (retry, discard etc).</p>
<pre><code class="hljs css language-c++"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;pulsar/Client.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;thread&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;atomic&gt;</span></span>
<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> pulsar;
<span class="hljs-built_in">std</span>::atomic&lt;<span class="hljs-keyword">uint32_t</span>&gt; acksReceived;
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">callback</span><span class="hljs-params">(Result code, <span class="hljs-keyword">const</span> MessageId&amp; msgId, <span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> msgContent)</span> </span>{
<span class="hljs-comment">// message processing logic here</span>
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Received ack for msg: "</span> &lt;&lt; msgContent &lt;&lt; <span class="hljs-string">" with code: "</span>
&lt;&lt; code &lt;&lt; <span class="hljs-string">" -- MsgID: "</span> &lt;&lt; msgId &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
acksReceived++;
}
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> </span>{
<span class="hljs-function"><span class="hljs-built_in">Client</span> <span class="hljs-title">client</span><span class="hljs-params">(<span class="hljs-string">"pulsar://localhost:6650"</span>)</span></span>;
ProducerConfiguration producerConf;
producerConf.setBlockIfQueueFull(<span class="hljs-literal">true</span>);
Producer producer;
Result result = client.createProducer(<span class="hljs-string">"persistent://public/default/my-topic"</span>,
producerConf, producer);
<span class="hljs-keyword">if</span> (result != ResultOk) {
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Error creating producer: "</span> &lt;&lt; result &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
<span class="hljs-keyword">return</span> <span class="hljs-number">-1</span>;
}
<span class="hljs-comment">// Send 100 messages asynchronously</span>
<span class="hljs-keyword">int</span> ctr = <span class="hljs-number">0</span>;
<span class="hljs-keyword">while</span> (ctr &lt; <span class="hljs-number">100</span>) {
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> content = <span class="hljs-string">"msg"</span> + <span class="hljs-built_in">std</span>::to_string(ctr);
Message msg = MessageBuilder().setContent(content).setProperty(<span class="hljs-string">"x"</span>, <span class="hljs-string">"1"</span>).build();
producer.sendAsync(msg, <span class="hljs-built_in">std</span>::bind(callback,
<span class="hljs-built_in">std</span>::placeholders::_1, <span class="hljs-built_in">std</span>::placeholders::_2, content));
<span class="hljs-built_in">std</span>::this_thread::sleep_for(<span class="hljs-built_in">std</span>::chrono::milliseconds(<span class="hljs-number">100</span>));
ctr++;
}
<span class="hljs-comment">// wait for 100 messages to be acked</span>
<span class="hljs-keyword">while</span> (acksReceived &lt; <span class="hljs-number">100</span>) {
<span class="hljs-built_in">std</span>::this_thread::sleep_for(<span class="hljs-built_in">std</span>::chrono::milliseconds(<span class="hljs-number">100</span>));
}
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Finished producing asynchronously!"</span> &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
client.<span class="hljs-built_in">close</span>();
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<h3><a class="anchor" aria-hidden="true" id="partitioned-topics-and-lazy-producers"></a><a href="#partitioned-topics-and-lazy-producers" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Partitioned topics and lazy producers</h3>
<p>When scaling out a Pulsar topic, you may configure a topic to have hundreds of partitions. Likewise, you may have also scaled out your producers so there are hundreds or even thousands of producers. This can put some strain on the Pulsar brokers as when you create a producer on a partitioned topic, internally it creates one internal producer per partition which involves communications to the brokers for each one. So for a topic with 1000 partitions and 1000 producers, it ends up creating 1,000,000 internal producers across the producer applications, each of which has to communicate with a broker to find out which broker it should connect to and then perform the connection handshake.</p>
<p>You can reduce the load caused by this combination of a large number of partitions and many producers by doing the following:</p>
<ul>
<li>use SinglePartition partition routing mode (this ensures that all messages are only sent to a single, randomly selected partition)</li>
<li>use non-keyed messages (when messages are keyed, routing is based on the hash of the key and so messages will end up being sent to multiple partitions)</li>
<li>use lazy producers (this ensures that an internal producer is only created on demand when a message needs to be routed to a partition)</li>
</ul>
<p>With our example above, that reduces the number of internal producers spread out over the 1000 producer apps from 1,000,000 to just 1000.</p>
<p>Note that there can be extra latency for the first message sent. If you set a low send timeout, this timeout could be reached if the initial connection handshake is slow to complete.</p>
<pre><code class="hljs css language-c++">ProducerConfiguration producerConf;
producerConf.setPartitionsRoutingMode(ProducerConfiguration::UseSinglePartition);
producerConf.setLazyStartPartitionedProducers(<span class="hljs-literal">true</span>);
</code></pre>
<h3><a class="anchor" aria-hidden="true" id="enable-chunking"></a><a href="#enable-chunking" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Enable chunking</h3>
<p>Message <a href="/docs/en/next/concepts-messaging#chunking">chunking</a> enables Pulsar to process large payload messages by splitting the message into chunks at the producer side and aggregating chunked messages at the consumer side.</p>
<p>The message chunking feature is OFF by default. The following is an example about how to enable message chunking when creating a producer.</p>
<pre><code class="hljs css language-c++">ProducerConfiguration conf;
conf.setBatchingEnabled(<span class="hljs-literal">false</span>);
conf.setChunkingEnabled(<span class="hljs-literal">true</span>);
Producer producer;
client.createProducer(<span class="hljs-string">"my-topic"</span>, conf, producer);
</code></pre>
<blockquote>
<p><strong>Note:</strong> To enable chunking, you need to disable batching (<code>setBatchingEnabled</code>=<code>false</code>) concurrently.</p>
</blockquote>
<h2><a class="anchor" aria-hidden="true" id="create-a-consumer"></a><a href="#create-a-consumer" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Create a consumer</h2>
<p>To use Pulsar as a consumer, you need to create a consumer on the C++ client. There are two main ways of using the consumer:</p>
<ul>
<li><a href="#blocking-example">Blocking style</a>: synchronously calling <code>receive(msg)</code>.</li>
<li><a href="#consumer-with-a-message-listener">Non-blocking</a> (event based) style: using a message listener.</li>
</ul>
<h3><a class="anchor" aria-hidden="true" id="blocking-example"></a><a href="#blocking-example" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Blocking example</h3>
<p>The benefit of this approach is that it is the simplest code. Simply keeps calling <code>receive(msg)</code> which blocks until a message is received.</p>
<p>This example starts a subscription at the earliest offset and consumes 100 messages.</p>
<pre><code class="hljs css language-c++"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;pulsar/Client.h&gt;</span></span>
<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> pulsar;
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> </span>{
<span class="hljs-function"><span class="hljs-built_in">Client</span> <span class="hljs-title">client</span><span class="hljs-params">(<span class="hljs-string">"pulsar://localhost:6650"</span>)</span></span>;
Consumer consumer;
ConsumerConfiguration <span class="hljs-built_in">config</span>;
<span class="hljs-built_in">config</span>.setSubscriptionInitialPosition(InitialPositionEarliest);
Result result = client.subscribe(<span class="hljs-string">"persistent://public/default/my-topic"</span>, <span class="hljs-string">"consumer-1"</span>, <span class="hljs-built_in">config</span>, consumer);
<span class="hljs-keyword">if</span> (result != ResultOk) {
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Failed to subscribe: "</span> &lt;&lt; result &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
<span class="hljs-keyword">return</span> <span class="hljs-number">-1</span>;
}
Message msg;
<span class="hljs-keyword">int</span> ctr = <span class="hljs-number">0</span>;
<span class="hljs-comment">// consume 100 messages</span>
<span class="hljs-keyword">while</span> (ctr &lt; <span class="hljs-number">100</span>) {
consumer.receive(msg);
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Received: "</span> &lt;&lt; msg
&lt;&lt; <span class="hljs-string">" with payload '"</span> &lt;&lt; msg.getDataAsString() &lt;&lt; <span class="hljs-string">"'"</span> &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
consumer.acknowledge(msg);
ctr++;
}
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Finished consuming synchronously!"</span> &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
client.<span class="hljs-built_in">close</span>();
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<h3><a class="anchor" aria-hidden="true" id="consumer-with-a-message-listener"></a><a href="#consumer-with-a-message-listener" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Consumer with a message listener</h3>
<p>You can avoid running a loop with blocking calls with an event based style by using a message listener which is invoked for each message that is received.</p>
<p>This example starts a subscription at the earliest offset and consumes 100 messages.</p>
<pre><code class="hljs css language-c++"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;pulsar/Client.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;atomic&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;thread&gt;</span></span>
<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> pulsar;
<span class="hljs-built_in">std</span>::atomic&lt;<span class="hljs-keyword">uint32_t</span>&gt; messagesReceived;
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">handleAckComplete</span><span class="hljs-params">(Result res)</span> </span>{
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Ack res: "</span> &lt;&lt; res &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
}
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">listener</span><span class="hljs-params">(Consumer consumer, <span class="hljs-keyword">const</span> Message&amp; msg)</span> </span>{
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Got message "</span> &lt;&lt; msg &lt;&lt; <span class="hljs-string">" with content '"</span> &lt;&lt; msg.getDataAsString() &lt;&lt; <span class="hljs-string">"'"</span> &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
messagesReceived++;
consumer.acknowledgeAsync(msg.getMessageId(), handleAckComplete);
}
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> </span>{
<span class="hljs-function"><span class="hljs-built_in">Client</span> <span class="hljs-title">client</span><span class="hljs-params">(<span class="hljs-string">"pulsar://localhost:6650"</span>)</span></span>;
Consumer consumer;
ConsumerConfiguration <span class="hljs-built_in">config</span>;
<span class="hljs-built_in">config</span>.setMessageListener(listener);
<span class="hljs-built_in">config</span>.setSubscriptionInitialPosition(InitialPositionEarliest);
Result result = client.subscribe(<span class="hljs-string">"persistent://public/default/my-topic"</span>, <span class="hljs-string">"consumer-1"</span>, <span class="hljs-built_in">config</span>, consumer);
<span class="hljs-keyword">if</span> (result != ResultOk) {
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Failed to subscribe: "</span> &lt;&lt; result &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
<span class="hljs-keyword">return</span> <span class="hljs-number">-1</span>;
}
<span class="hljs-comment">// wait for 100 messages to be consumed</span>
<span class="hljs-keyword">while</span> (messagesReceived &lt; <span class="hljs-number">100</span>) {
<span class="hljs-built_in">std</span>::this_thread::sleep_for(<span class="hljs-built_in">std</span>::chrono::milliseconds(<span class="hljs-number">100</span>));
}
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Finished consuming asynchronously!"</span> &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
client.<span class="hljs-built_in">close</span>();
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<h3><a class="anchor" aria-hidden="true" id="configure-chunking"></a><a href="#configure-chunking" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Configure chunking</h3>
<p>You can limit the maximum number of chunked messages a consumer maintains concurrently by configuring the <code>setMaxPendingChunkedMessage</code> and <code>setAutoAckOldestChunkedMessageOnQueueFull</code> parameters. When the threshold is reached, the consumer drops pending messages by silently acknowledging them or asking the broker to redeliver them later.</p>
<p>The following is an example of how to configure message chunking.</p>
<pre><code class="hljs css language-c++">ConsumerConfiguration conf;
conf.setAutoAckOldestChunkedMessageOnQueueFull(<span class="hljs-literal">true</span>);
conf.setMaxPendingChunkedMessage(<span class="hljs-number">100</span>);
Consumer consumer;
client.subscribe(<span class="hljs-string">"my-topic"</span>, <span class="hljs-string">"my-sub"</span>, conf, consumer);
</code></pre>
<h2><a class="anchor" aria-hidden="true" id="enable-authentication-in-connection-urls"></a><a href="#enable-authentication-in-connection-urls" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Enable authentication in connection URLs</h2>
<p>If you use TLS authentication when connecting to Pulsar, you need to add <code>ssl</code> in the connection URLs, and the default port is <code>6651</code>. The following is an example.</p>
<pre><code class="hljs css language-cpp">ClientConfiguration config = ClientConfiguration();
config.setUseTls(<span class="hljs-literal">true</span>);
config.setTlsTrustCertsFilePath(<span class="hljs-string">"/path/to/cacert.pem"</span>);
config.setTlsAllowInsecureConnection(<span class="hljs-literal">false</span>);
config.setAuth(pulsar::AuthTls::create(
<span class="hljs-string">"/path/to/client-cert.pem"</span>, <span class="hljs-string">"/path/to/client-key.pem"</span>););
<span class="hljs-function">Client <span class="hljs-title">client</span><span class="hljs-params">(<span class="hljs-string">"pulsar+ssl://my-broker.com:6651"</span>, config)</span></span>;
</code></pre>
<p>For complete examples, refer to <a href="https://github.com/apache/pulsar/tree/master/pulsar-client-cpp/examples">C++ client examples</a>.</p>
<h2><a class="anchor" aria-hidden="true" id="schema"></a><a href="#schema" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Schema</h2>
<p>This section describes some examples about schema. For more information about
schema, see <a href="/docs/en/next/schema-get-started">Pulsar schema</a>.</p>
<h3><a class="anchor" aria-hidden="true" id="avro-schema"></a><a href="#avro-schema" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Avro schema</h3>
<ul>
<li><p>The following example shows how to create a producer with an Avro schema.</p>
<pre><code class="hljs css language-cpp"><span class="hljs-keyword">static</span> <span class="hljs-keyword">const</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> exampleSchema =
<span class="hljs-string">"{\"type\":\"record\",\"name\":\"Example\",\"namespace\":\"test\","</span>
<span class="hljs-string">"\"fields\":[{\"name\":\"a\",\"type\":\"int\"},{\"name\":\"b\",\"type\":\"int\"}]}"</span>;
Producer producer;
ProducerConfiguration producerConf;
producerConf.setSchema(SchemaInfo(AVRO, <span class="hljs-string">"Avro"</span>, exampleSchema));
client.createProducer(<span class="hljs-string">"topic-avro"</span>, producerConf, producer);
</code></pre></li>
<li><p>The following example shows how to create a consumer with an Avro schema.</p>
<pre><code class="hljs css language-cpp"><span class="hljs-keyword">static</span> <span class="hljs-keyword">const</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> exampleSchema =
<span class="hljs-string">"{\"type\":\"record\",\"name\":\"Example\",\"namespace\":\"test\","</span>
<span class="hljs-string">"\"fields\":[{\"name\":\"a\",\"type\":\"int\"},{\"name\":\"b\",\"type\":\"int\"}]}"</span>;
ConsumerConfiguration consumerConf;
Consumer consumer;
consumerConf.setSchema(SchemaInfo(AVRO, <span class="hljs-string">"Avro"</span>, exampleSchema));
client.subscribe(<span class="hljs-string">"topic-avro"</span>, <span class="hljs-string">"sub-2"</span>, consumerConf, consumer)
</code></pre></li>
</ul>
<h3><a class="anchor" aria-hidden="true" id="protobufnative-schema"></a><a href="#protobufnative-schema" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>ProtobufNative schema</h3>
<p>The following example shows how to create a producer and a consumer with a ProtobufNative schema.
</p>
<ol>
<li><p>Generate the <code>User</code> class using Protobuf3.</p>
<blockquote>
<p><strong>Note</strong> <br>
You need to use Protobuf3 or later versions.
</p>
</blockquote>
<pre><code class="hljs css language-protobuf">syntax = <span class="hljs-string">"proto3"</span>;
<span class="hljs-class"><span class="hljs-keyword">message</span> <span class="hljs-title">User</span> </span>{
<span class="hljs-built_in">string</span> name = <span class="hljs-number">1</span>;
<span class="hljs-built_in">int32</span> age = <span class="hljs-number">2</span>;
}
</code></pre></li>
</ol>
<p></p>
<ol start="2">
<li>Include the <code>ProtobufNativeSchema.h</code> in your source code. Ensure the Protobuf dependency has been added to your project.
<pre><code class="hljs css language-c++"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;pulsar/ProtobufNativeSchema.h&gt;</span></span>
</code></pre></li>
</ol>
<p></p>
<ol start="3">
<li>Create a producer to send a <code>User</code> instance.
<pre><code class="hljs css language-c++">ProducerConfiguration producerConf;
producerConf.setSchema(createProtobufNativeSchema(User::GetDescriptor()));
Producer producer;
client.createProducer(<span class="hljs-string">"topic-protobuf"</span>, producerConf, producer);
User user;
user.set_name(<span class="hljs-string">"my-name"</span>);
user.set_age(<span class="hljs-number">10</span>);
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> content;
user.SerializeToString(&amp;content);
producer.send(MessageBuilder().setContent(content).build());
</code></pre></li>
</ol>
<p></p>
<ol start="4">
<li>Create a consumer to receive a <code>User</code> instance.
<pre><code class="hljs css language-c++">ConsumerConfiguration consumerConf;
consumerConf.setSchema(createProtobufNativeSchema(User::GetDescriptor()));
consumerConf.setSubscriptionInitialPosition(InitialPositionEarliest);
Consumer consumer;
client.subscribe(<span class="hljs-string">"topic-protobuf"</span>, <span class="hljs-string">"my-sub"</span>, consumerConf, consumer);
Message msg;
consumer.receive(msg);
User user2;
user2.ParseFromArray(msg.getData(), msg.getLength());
</code></pre></li>
</ol>
</span></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/en/next/client-libraries-python"><span class="arrow-prev"></span><span>Python</span></a><a class="docs-next button" href="/docs/en/next/client-libraries-node"><span>Node.js</span><span class="arrow-next"></span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#supported-platforms">Supported platforms</a></li><li><a href="#linux">Linux</a><ul class="toc-headings"><li><a href="#compilation">Compilation</a></li><li><a href="#install-dependencies">Install Dependencies</a></li><li><a href="#install-rpm">Install RPM</a></li><li><a href="#install-debian">Install Debian</a></li><li><a href="#build">Build</a></li></ul></li><li><a href="#macos">MacOS</a><ul class="toc-headings"><li><a href="#compilation-1">Compilation</a></li><li><a href="#install-libpulsar">Install <code>libpulsar</code></a></li></ul></li><li><a href="#windows-64-bit">Windows (64-bit)</a><ul class="toc-headings"><li><a href="#compilation-2">Compilation</a></li></ul></li><li><a href="#connection-urls">Connection URLs</a></li><li><a href="#create-a-producer">Create a producer</a><ul class="toc-headings"><li><a href="#simple-blocking-example">Simple blocking example</a></li><li><a href="#non-blocking-example">Non-blocking example</a></li><li><a href="#partitioned-topics-and-lazy-producers">Partitioned topics and lazy producers</a></li><li><a href="#enable-chunking">Enable chunking</a></li></ul></li><li><a href="#create-a-consumer">Create a consumer</a><ul class="toc-headings"><li><a href="#blocking-example">Blocking example</a></li><li><a href="#consumer-with-a-message-listener">Consumer with a message listener</a></li><li><a href="#configure-chunking">Configure chunking</a></li></ul></li><li><a href="#enable-authentication-in-connection-urls">Enable authentication in connection URLs</a></li><li><a href="#schema">Schema</a><ul class="toc-headings"><li><a href="#avro-schema">Avro schema</a></li><li><a href="#protobufnative-schema">ProtobufNative schema</a></li></ul></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="copyright">Copyright © 2022 The Apache Software Foundation. All Rights Reserved. Apache, Apache Pulsar and the Apache feather logo are trademarks of The Apache Software Foundation.</section><span><script>
const community = document.querySelector("a[href='#community']").parentNode;
const communityMenu =
'<li>' +
'<a id="community-menu" href="#">Community <span style="font-size: 0.75em">&nbsp;▼</span></a>' +
'<div id="community-dropdown" class="hide">' +
'<ul id="community-dropdown-items">' +
'<li><a href="/en/contact">Contact</a></li>' +
'<li><a href="/en/contributing">Contributing</a></li>' +
'<li><a href="/en/coding-guide">Coding guide</a></li>' +
'<li><a href="/en/events">Events</a></li>' +
'<li><a href="https://twitter.com/Apache_Pulsar" target="_blank">Twitter &#x2750</a></li>' +
'<li><a href="https://github.com/apache/pulsar/wiki" target="_blank">Wiki &#x2750</a></li>' +
'<li><a href="https://github.com/apache/pulsar/issues" target="_blank">Issue tracking &#x2750</a></li>' +
'<li><a href="https://pulsar-summit.org/" target="_blank">Pulsar Summit &#x2750</a></li>' +
'<li>&nbsp;</li>' +
'<li><a href="/en/resources">Resources</a></li>' +
'<li><a href="/en/team">Team</a></li>' +
'<li><a href="/en/powered-by">Powered By</a></li>' +
'</ul>' +
'</div>' +
'</li>';
community.innerHTML = communityMenu;
const communityMenuItem = document.getElementById("community-menu");
const communityDropDown = document.getElementById("community-dropdown");
communityMenuItem.addEventListener("click", function(event) {
event.preventDefault();
if (communityDropDown.className == 'hide') {
communityDropDown.className = 'visible';
} else {
communityDropDown.className = 'hide';
}
});
</script></span></footer></div><script>window.twttr=(function(d,s, id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src='https://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js, fjs);t._e = [];t.ready = function(f) {t._e.push(f);};return t;}(document, 'script', 'twitter-wjs'));</script></body></html>