blob: 2da72056e1a848fbc2a0b3cbfee70da947a336c5 [file]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.7"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>pulsar-client-cpp: pulsar-client-cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript" src="darkmode_toggle.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">pulsar-client-cpp
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.7 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div><div class="header">
<div class="headertitle"><div class="title">pulsar-client-cpp </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="md__r_e_a_d_m_e"></a></p>
<h1>Pulsar C++ client library</h1>
<p>Pulsar C++ clients support a variety of Pulsar features to enable building applications connecting to your Pulsar cluster.</p>
<p>For the supported Pulsar features, see <a href="https://pulsar.apache.org/client-feature-matrix/">Client Feature Matrix</a>.</p>
<p>For how to use APIs to publish and consume messages, see <a href="https://github.com/apache/pulsar-client-cpp/tree/main/examples">examples</a>.</p>
<h2>Generate the API documents</h2>
<p>Pulsar C++ client uses <a href="https://www.doxygen.nl">doxygen</a> to build API documents. After installing <code>doxygen</code>, you only need to run <code>doxygen</code> to generate the API documents whose main page is under the <code>doxygen/html/index.html</code> path.</p>
<h2>Requirements</h2>
<ul>
<li>A C++ compiler that supports C++11, like GCC &gt;= 4.8</li>
<li>CMake &gt;= 3.13</li>
<li><a href="http://www.boost.org/">Boost</a></li>
<li><a href="https://developers.google.com/protocol-buffers/">Protocol Buffer</a> &gt;= 3</li>
<li><a href="https://curl.se/libcurl/">libcurl</a></li>
<li><a href="https://github.com/openssl/openssl">openssl</a></li>
</ul>
<p>The default supported <a href="include/pulsar/CompressionType.h">compression types</a> are:</p>
<ul>
<li><code>CompressionNone</code></li>
<li><code>CompressionLZ4</code></li>
</ul>
<p>If you want to enable other compression types, you need to install:</p>
<ul>
<li><code>CompressionZLib</code>: <a href="https://zlib.net/">zlib</a></li>
<li><code>CompressionZSTD</code>: <a href="https://github.com/facebook/zstd">zstd</a></li>
<li><code>CompressionSNAPPY</code>: <a href="https://github.com/google/snappy">snappy</a></li>
</ul>
<p>If you want to build and run the tests, you need to install <a href="https://github.com/google/googletest">GTest</a>. Otherwise, you need to add CMake option <code>-DBUILD_TESTS=OFF</code>.</p>
<p>The <a href="./dependencies.yaml">dependencies.yaml</a> file provides the recommended dependency versions, while you can still build from source with other dependency versions. If a dependency requires a higher C++ standard, e.g. C++14, you can specify the standard like:</p>
<div class="fragment"><div class="line">cmake . -DCMAKE_CXX_STANDARD=14</div>
</div><!-- fragment --><blockquote class="doxtable">
<p>&zwj;<b>Note</b>:</p>
<p>On macOS, the default C++ standard is 17 because the latest Protobuf from Homebrew requires the C++17 support. </p>
</blockquote>
<h2>Platforms</h2>
<p>Pulsar C++ Client Library has been tested on:</p>
<ul>
<li>Linux</li>
<li>Mac OS X</li>
<li>Windows x64</li>
</ul>
<h2>Compilation</h2>
<h3>Clone</h3>
<p>First of all, clone the source code:</p>
<div class="fragment"><div class="line">git clone https://github.com/apache/pulsar-client-cpp</div>
<div class="line">cd pulsar-client-cpp</div>
</div><!-- fragment --><h3>Compile on Ubuntu</h3>
<h4>Install all dependencies:</h4>
<div class="fragment"><div class="line">sudo apt-get update -y &amp;&amp; sudo apt-get install -y g++ cmake libssl-dev libcurl4-openssl-dev \</div>
<div class="line"> libprotobuf-dev libboost-all-dev libgtest-dev libgmock-dev \</div>
<div class="line"> protobuf-compiler</div>
</div><!-- fragment --><h4>Compile Pulsar client library:</h4>
<div class="fragment"><div class="line">cmake .</div>
<div class="line">make</div>
</div><!-- fragment --><p>If you want to build performance tools, you need to run:</p>
<div class="fragment"><div class="line">cmake . -DBUILD_PERF_TOOLS=ON</div>
<div class="line">make</div>
</div><!-- fragment --><h4>Checks</h4>
<p>Client library will be placed in:</p>
<div class="fragment"><div class="line">lib/libpulsar.so</div>
<div class="line">lib/libpulsar.a</div>
</div><!-- fragment --><p>Examples will be placed in:</p>
<div class="fragment"><div class="line">examples/</div>
</div><!-- fragment --><p>Tools will be placed in:</p>
<div class="fragment"><div class="line">perf/perfProducer</div>
<div class="line">perf/perfConsumer</div>
</div><!-- fragment --><h3>Compile on Mac OS X</h3>
<h4>Install all dependencies:</h4>
<div class="fragment"><div class="line">brew install cmake openssl protobuf boost googletest zstd snappy</div>
</div><!-- fragment --><h4>Compile Pulsar client library:</h4>
<div class="fragment"><div class="line">cmake .</div>
<div class="line">make</div>
</div><!-- fragment --><p>If you want to build performance tools, you need to run:</p>
<div class="fragment"><div class="line">cmake . -DBUILD_PERF_TOOLS=ON</div>
<div class="line">make</div>
</div><!-- fragment --><h4>Checks</h4>
<p>Client library will be placed in:</p>
<div class="fragment"><div class="line">lib/libpulsar.dylib</div>
<div class="line">lib/libpulsar.a</div>
</div><!-- fragment --><p>Examples will be placed in:</p>
<div class="fragment"><div class="line">examples/</div>
</div><!-- fragment --><p>Tools will be placed in:</p>
<div class="fragment"><div class="line">perf/perfProducer</div>
<div class="line">perf/perfConsumer</div>
</div><!-- fragment --><h3>Compile on Windows</h3>
<h4>Install with <a href="https://github.com/microsoft/vcpkg">vcpkg</a></h4>
<p>It's highly recommended to use <code>vcpkg</code> for C++ package management on Windows. It's easy to install and well supported by Visual Studio (2015/2017/2019) and CMake. See <a href="https://github.com/microsoft/vcpkg#quick-start-windows">here</a> for quick start.</p>
<p>Take Windows 64-bit library as an example, you only need to run</p>
<div class="fragment"><div class="line">vcpkg install --feature-flags=manifests --triplet x64-windows</div>
</div><!-- fragment --><blockquote class="doxtable">
<p>&zwj;<b>NOTE</b>:</p>
<p>For Windows 32-bit library, change <code>x64-windows</code> to <code>x86-windows</code>, see <a href="https://github.com/microsoft/vcpkg/blob/master/docs/users/triplets.md">here</a> for more details about the triplet concept in Vcpkg. </p>
</blockquote>
<p>The all dependencies, which are specified by <a href="vcpkg.json">vcpkg.json</a>, will be installed in <code>vcpkg_installed/</code> subdirectory,</p>
<p>With <code>vcpkg</code>, you only need to run two commands:</p>
<div class="fragment"><div class="line">cmake \</div>
<div class="line"> -B ./build \</div>
<div class="line"> -A x64 \</div>
<div class="line"> -DBUILD_TESTS=OFF \</div>
<div class="line"> -DVCPKG_TRIPLET=x64-windows \</div>
<div class="line"> -DCMAKE_BUILD_TYPE=Release \</div>
<div class="line"> -S .</div>
<div class="line">cmake --build ./build --config Release</div>
</div><!-- fragment --><p>Then all artifacts will be built into <code>build</code> subdirectory.</p>
<blockquote class="doxtable">
<p>&zwj;<b>NOTE</b>:</p>
<ol type="1">
<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>
<h4>Install dependencies manually</h4>
<p>You need to install <a href="https://github.com/dlfcn-win32/dlfcn-win32">dlfcn-win32</a> in addition.</p>
<p>If you installed the dependencies manually, you need to run</p>
<div class="fragment"><div class="line">#If all dependencies are in your path, all that is necessary is</div>
<div class="line">cmake .</div>
<div class="line"> </div>
<div class="line">#if all dependencies are not in your path, then passing in a PROTOC_PATH and CMAKE_PREFIX_PATH is necessary</div>
<div class="line">cmake -DPROTOC_PATH=C:/protobuf/bin/protoc -DCMAKE_PREFIX_PATH=&quot;C:/boost;C:/openssl;C:/zlib;C:/curl;C:/protobuf;C:/googletest;C:/dlfcn-win32&quot; .</div>
<div class="line"> </div>
<div class="line">#This will generate pulsar-cpp.sln. Open this in Visual Studio and build the desired configurations.</div>
</div><!-- fragment --><h4>Checks</h4>
<p>Client library will be placed in:</p>
<div class="fragment"><div class="line">build/lib/Release/pulsar.lib</div>
<div class="line">build/lib/Release/pulsar.dll</div>
</div><!-- fragment --><h4>Examples</h4>
<p>Add Windows environment paths:</p>
<div class="fragment"><div class="line">build/lib/Release</div>
<div class="line">vcpkg_installed</div>
</div><!-- fragment --><p>Examples will be available in:</p>
<div class="fragment"><div class="line">build/examples/Release</div>
</div><!-- fragment --><h2>Tests</h2>
<div class="fragment"><div class="line"># Execution</div>
<div class="line"># Start standalone broker</div>
<div class="line">./pulsar-test-service-start.sh</div>
<div class="line"> </div>
<div class="line"># Run the tests</div>
<div class="line">cd tests</div>
<div class="line">./pulsar-tests</div>
<div class="line"> </div>
<div class="line"># When no longer needed, stop standalone broker</div>
<div class="line">./pulsar-test-service-stop.sh</div>
</div><!-- fragment --><h2>Wireshark Dissector</h2>
<p>See the <a href="wireshark/">wireshark</a> directory for details.</p>
<h2>Requirements for Contributors</h2>
<p>It's required to install <a href="https://llvm.org/builds/">LLVM</a> for <code>clang-tidy</code> and <code>clang-format</code>. Pulsar C++ client use <code>clang-format</code> <b>11</b> to format files. <code>make format</code> automatically formats the files.</p>
<p>For Ubuntu users, you can install <code>clang-format-11</code> via <code>apt install clang-format-11</code>. For other users, run <code>./build-support/docker-format.sh</code> if you have Docker installed.</p>
<p>We welcome contributions from the open source community, kindly make sure your changes are backward compatible with GCC 4.8 and Boost 1.53.</p>
<p>If your contribution adds Pulsar features for C++ clients, you need to update both the <a href="https://pulsar.apache.org/docs/client-libraries/">Pulsar docs</a> and the <a href="https://pulsar.apache.org/client-feature-matrix/">Client Feature Matrix</a>. See <a href="https://pulsar.apache.org/contribute/site-intro/#pages">Contribution Guide</a> for more details. </p>
</div></div><!-- PageDoc -->
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.7
</small></address>
</body>
</html>