Skip to content

RobertIndie/pulsar-dotpulsar

 
 

Repository files navigation

DotPulsar

CI - Unit

The official .NET client library for Apache Pulsar.

DotPulsar is written entirely in C# and implements Apache Pulsar's binary protocol.

What's new?

Have a look at the changelog.

Getting Started

Let's take a look at a "Hello world" example, where we first produce a message and then consume it. Note that the topic and subscription will be created if they don't exist.

First, we need a Pulsar setup. Have a look here to see how to setup a local standalone Pulsar instance. Install the NuGet package DotPulsar and copy/paste the code below (you will be needing using declarations for 'DotPulsar' and 'DotPulsar.Extensions').

const string myTopic = "persistent://public/default/mytopic";

await using var client = PulsarClient.Builder()
                                     .Build(); // Connecting to pulsar://localhost:6650

await using var producer = client.NewProducer(Schema.String)
                                 .Topic(myTopic)
                                 .Create();

_ = await producer.Send("Hello World"); // Send a message and ignore the returned MessageId

await using var consumer = client.NewConsumer(Schema.String)
                                 .SubscriptionName("MySubscription")
                                 .Topic(myTopic)
                                 .InitialPosition(SubscriptionInitialPosition.Earliest)
                                 .Create();

await foreach (var message in consumer.Messages())
{
    Console.WriteLine($"Received: {message.Value()}");
    await consumer.Acknowledge(message);
}

For a more in-depth tour of the API, please visit the Wiki.

Supported features

  • Service discovery
  • Automatic reconnect
  • TLS connections
  • Pulsar Proxy
  • Producer send with custom metadata
  • Producer send with event time, sequence id, and delayed message delivery
  • Producer send with key and ordering key
  • Producer for partitioned topics
  • Consumer subscription with initial position and priority level
  • Consumer subscription types exclusive, shared, failover, and key shared
  • Consumer receive and single + cumulative acknowledge
  • Consumer and Reader seek on message-id and publish time
  • Consumer unsubscribe
  • Consume compacted topics
  • Reader API
  • Read/Consume/Acknowledge batched messages
  • Telemetry
  • Authentication
    • TLS Authentication
    • JSON Web Token Authentication
    • Custom Authentication
  • Message compression
    • LZ4
    • ZLIB
    • ZSTD
    • SNAPPY
  • Schemas
    • Boolean
    • Bytes (using byte[] and ReadOnlySequence<byte>)
    • String (UTF-8, UTF-16, and US-ASCII)
    • INT8, INT16, INT32, and INT64
    • Float and Double
    • Time (using TimeSpan)
    • Timestamp and Date (using DateTime)

Roadmap

Help prioritizing the roadmap is most welcome, so please reach out and tell us what you want and need.

Join Our Community

Apache Pulsar has a Slack instance and there you'll find us in the #dev-dotpulsar channel.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the Apache License Version 2.0 - see the LICENSE file for details.

About

.NET/C# client library for Apache Pulsar

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%