IReader.HasMessageAvailableAsync incorrectly returns false when MessageIdInclusive=true
See original GitHub issueHasMessageAvailableAsync
as it always returns false for the last message only when StartMessageIdInclusive(true)
is configured. This seems like a bug.
Is it expected that the C# test case below fails on the last assertion?
private async Task MessageIdInclusive_HasMessageAvailableAsync(string topic, PulsarClient client)
{
await using var producer = await client.NewProducer().Topic(topic).CreateAsync();
var previousMessageId = await producer.SendAsync(new byte[] { 1 });
var expectedMessageId = await producer.SendAsync(new byte[] { 2 });
// MessageId Exclusive works as expected
await using var exclusiveReader = await client.NewReader().Topic(topic)
.StartMessageId(previousMessageId).StartMessageIdInclusive(false).CreateAsync();
var available = await exclusiveReader.HasMessageAvailableAsync();
var actual = await exclusiveReader.ReadNextAsync();
AssertEqual(expectedMessageId, actual);
Assert.True(available);
// MessageId Inclusive
await using var inclusiveReader = await client.NewReader().Topic(topic)
.StartMessageId(expectedMessageId).StartMessageIdInclusive(true).CreateAsync();
available = await inclusiveReader.HasMessageAvailableAsync();
actual = await inclusiveReader.ReadNextAsync();
AssertEqual(expectedMessageId, actual);
Assert.True(available); // <===== this assertion fails while a message was available??
}
The problem seems to be at line https://github.com/fsharplang-ru/pulsar-client-dotnet/blob/d80640ea82410479f60ff23f1e3b7f0d9554202c/src/Pulsar.Client/Internal/ConsumerImpl.fs#L132
When debugging my test case lastMessageIdInBroker
and lastDequeuedMessageId
are equal except for the Type, respectively Individual
and Cumulative(0,null)
.
So my test case passes if I modify MessageId.CompareTo
and ignore the Type when comparing.
I have no experience with the code base, so this is probably not a proper solution.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, I’ll have a look tomorrow. In a while you can create a failing test in this file https://github.com/fsharplang-ru/pulsar-client-dotnet/blob/develop/tests/IntegrationTests/Reader.fs and send a PR to merge
You are welcome! Yes, it doesn’t need to change as it conforms to the Java version.