To set up C# client library in Pulsar, complete the following steps.
Step 1: Install C# client library
This section describes how to install the Pulsar C# client library through the dotnet CLI.
Alternatively, you can install the Pulsar C# client library through Visual Studio. Note that starting from Visual Studio 2017, the dotnet CLI is automatically installed with any .NET Core related workloads. For more information, see Microsoft documentation.
To install the Pulsar C# client library using the dotnet CLI, follow these steps:
Install the .NET Core SDK, which provides the dotnet CLI.
Create a project.
Create a folder for the project.
Open a terminal window and switch to the new folder.
Create the project using the following command.
dotnet new console
dotnet runto test that the app has been created properly.
Add the DotPulsar NuGet package.
Use the following command to install the
dotnet add package DotPulsar
After the command completes, open the
.csprojfile to see the added reference.
<PackageReference Include="DotPulsar" Version="2.0.1" />
Step 2: Connect to Pulsar cluster
To connect to Pulsar using client libraries, you need to specify a Pulsar protocol URL.
You can assign Pulsar protocol URLs to specific clusters and use the
pulsar scheme. The following is an example of
localhost with the default port
If you have multiple brokers, separate
IP:port by commas:
If you use mTLS authentication, add
+ssl in the scheme: