Consumer and Reader do not throw FaultedException as excepted. (#176)

The Consumer and Reader didn't throw FaultedException in two scenarios where it should.

Consumer
1:
After the initial setup of the DotPulsar client where it can't connect to the cluster. Creating a consumer and using Receive didn't produce a ConsumerFaultedException as it should.

2:
After the initial setup of the DotPulsar client where it can't connect to the cluster and is in a faulted state. Creating a consumer and using Receive didn't produce a ConsumerFaultedException as it should.

Reader
1:
After the initial setup of the DotPulsar client where it can't connect to the cluster. Creating a reader and using Receive didn't produce a ReaderFaultedException as it should.

2:
After the initial setup of the DotPulsar client where it can't connect to the cluster and is in a faulted state. Creating a reader and using Receive didn't produce a ReaderFaultedException as it should.

All the scenarios are fixed, and tests are written in ConsumerTests.cs ReaderTests.cs confirming the fix.

Co-authored-by: David Jensen <djn@danskecommodities.com>
7 files changed
tree: b6a211907928da282b732a0145efedba500de104
  1. .github/
  2. docs/
  3. samples/
  4. src/
  5. tests/
  6. .asf.yaml
  7. .editorconfig
  8. .gitattributes
  9. .gitignore
  10. CHANGELOG.md
  11. CONTRIBUTING.md
  12. DotPulsar.sln
  13. DotPulsar.sln.DotSettings
  14. LICENSE
  15. NOTICE
  16. README.md
README.md

# 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. See Pulsar docs for how to set up a local standalone Pulsar instance.

Install the NuGet package DotPulsar and run the follow code example:

using DotPulsar;
using DotPulsar.Extensions;

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

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

// produce a message
await using var producer = client.NewProducer(Schema.String).Topic(myTopic).Create();
await producer.Send("Hello World");

// consume messages
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

  • [X] Service discovery
  • [X] Automatic reconnect
  • [X] TLS connections
  • [X] Pulsar Proxy
  • [X] Producer - send with custom metadata
  • [X] Producer - send with event time, sequence id, and delayed message delivery
  • [X] Producer - send with key and ordering key
  • [X] Producer - partitioned topics
  • [X] Consumer - subscription with initial position and priority level
  • [X] Consumer - subscription types exclusive, shared, failover, and key shared
  • [X] Consumer - receive and single + cumulative acknowledge
  • [X] Consumer/Reader - seek on message-id and publish time
  • [X] Consumer - unsubscribe
  • [X] Consumer - compacted topics
  • [X] Reader API
  • [X] Read/Consume/Acknowledge batched messages
  • [X] Telemetry
  • [X] Authentication
    • TLS Authentication
    • JSON Web Token Authentication
    • Custom Authentication
  • [X] Message compression
    • LZ4
    • ZLIB
    • ZSTD
    • SNAPPY
  • [X] 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)

For a horizontal comparison with more language-specific clients, see Client Feature Matrix.

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

Contributions are welcomed and greatly appreciated. See also the list of contributors who participated in this project. Read the CONTRIBUTING guide for how to participate.

If your contribution adds Pulsar features for C# clients, you need to update both the Pulsar docs and the Client Feature Matrix. See Contribution Guide for more details.

License

This project is licensed under Apache License, Version 2.0.