This is an automated email from the ASF dual-hosted git repository.

blankensteiner pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-dotpulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new f7d4981  GetLastMessageId(s) (#175)
f7d4981 is described below

commit f7d49813f6d49b74ac894709cf94f000f242216b
Author: entvex <[email protected]>
AuthorDate: Mon Sep 11 14:41:15 2023 +0200

    GetLastMessageId(s) (#175)
    
    When calling GetLastMessageId(s) method on a Reader or Consumer, it returns 
a MessageId without the topic field if MessageId.Earliest is found.
    
    Co-authored-by: David Jensen <[email protected]>
---
 CHANGELOG.md                              | 7 +++++++
 src/DotPulsar/Internal/ConsumerChannel.cs | 8 +++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 932f2e5..f77e0f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this 
file.
 
 The format is based on [Keep a 
Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to 
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+## [Unreleased]
+
+### Changed
+
+- When calling GetLastMessageId(s) on a Reader or Consumer, it returns a 
MessageId without the topic field if
+  MessageId.Earliest is found.
+
 ## [3.0.0] - 2023-08-30
 
 ### Added
diff --git a/src/DotPulsar/Internal/ConsumerChannel.cs 
b/src/DotPulsar/Internal/ConsumerChannel.cs
index e95f23f..f90b7f4 100644
--- a/src/DotPulsar/Internal/ConsumerChannel.cs
+++ b/src/DotPulsar/Internal/ConsumerChannel.cs
@@ -184,7 +184,13 @@ public sealed class ConsumerChannel<TMessage> : 
IConsumerChannel<TMessage>
         command.ConsumerId = _id;
         var response = await _connection.Send(command, 
cancellationToken).ConfigureAwait(false);
         response.Expect(BaseCommand.Type.GetLastMessageIdResponse);
-        return 
response.GetLastMessageIdResponse.LastMessageId.ToMessageId(_topic);
+        var messageIdData = response.GetLastMessageIdResponse.LastMessageId;
+        if (messageIdData.LedgerId == MessageId.Earliest.LedgerId &&
+            messageIdData.EntryId == MessageId.Earliest.EntryId &&
+            messageIdData.Partition == MessageId.Earliest.Partition &&
+            messageIdData.BatchIndex == MessageId.Earliest.BatchIndex)
+            return MessageId.Earliest;
+        return messageIdData.ToMessageId(_topic);
     }
 
     public async ValueTask DisposeAsync()

Reply via email to