entvex commented on issue #169:
URL:
https://github.com/apache/pulsar-dotpulsar/issues/169#issuecomment-1680509286
Hi @Ceyword. It works but as @blankensteiner pointed towards you need to set
it to be a shared or key-shared subscription.
The following code will hold the message for 1 min.
```Csharp
await Task.Run(async () =>
{
const string myTopic = "TestScheduling";
await using var client =
DotPulsar.PulsarClient.Builder().ServiceUrl(new
Uri("pulsar://127.0.0.1:6650")).Build();
await using var producer =
client.NewProducer(DotPulsar.Schema.String).Topic(myTopic).Create();
await producer.Send("Hello Pulsar now");
await producer.Send(new DotPulsar.MessageMetadata {
DeliverAtTimeAsDateTime = DateTime.UtcNow.AddMinutes(1) }, "Hello Pulsar after
1 minutes");
await using var consumer =
client.NewConsumer(DotPulsar.Schema.String)
.SubscriptionName("MySubscription")
.Topic(myTopic)
.InitialPosition(DotPulsar.SubscriptionInitialPosition.Latest)
.SubscriptionType(SubscriptionType.Shared)
.Create();
var messages = consumer.Messages();
await foreach (var message in messages)
{
Console.WriteLine($"Received:
{Encoding.UTF8.GetString(message.Data.ToArray())} @ {DateTime.UtcNow}");
await consumer.Acknowledge(message);
}
});
```
I hope it makes sense 😄
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]