DR9885 opened a new issue, #15317:
URL: https://github.com/apache/pulsar/issues/15317
**Describe the bug**
If events are consumed as key_shared, and the first event was nacked it
changes the order of the events for that key. It has that event pushed to the
end.
This is an issue, when building a materialized view based off a key/id. If
the events are played out of order it could change the resulting object.
**To Reproduce**
C# test example
```
public class ExampleTest
{
[Fact]
public async Task Test()
{
const int size = 10;
const string topic = "persistent://public/default/topic";
var client = await new PulsarClientBuilder()
.ServiceUrl("pulsar://localhost:6650")
.BuildAsync();
var producer = await client.NewProducer()
.Topic(topic)
.BatchBuilder(BatchBuilder.KeyBased)
.CreateAsync();
for (var i = 0; i < size; i++)
{
var payload = Encoding.UTF8.GetBytes($"message-{i}");
var msg = producer.NewMessage(payload, $"key-{i}");
await producer.SendAsync(msg);
}
var subscribe = await client.NewConsumer()
.Topic(topic)
.SubscriptionName("test-group")
.SubscriptionType(SubscriptionType.KeyShared)
.SubscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
.SubscribeAsync();
var batch = await subscribe.ReceiveAsync();
await subscribe.NegativeAcknowledge(batch.MessageId);
for (var i = 0; i < size; i++)
{
var item = await subscribe.ReceiveAsync();
Assert.Equal($"key-{i}", item.Key);
}
}
}
```
**Expected behavior**
It should wait to further events from that key
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: Windows 11
**Additional context**
Note: if retry limit is hit, the messages would never play. so maybe there
should also be a way to reset retry counts to try again.
--
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]