BewareMyPower commented on a change in pull request #14604:
URL: https://github.com/apache/pulsar/pull/14604#discussion_r832441150
##########
File path: pulsar-client-cpp/lib/ConsumerImpl.cc
##########
@@ -1228,8 +1243,15 @@ void ConsumerImpl::seekAsync(const MessageId& msgId,
ResultCallback callback) {
uint64_t requestId = client->newRequestId();
LOG_DEBUG(getName() << " Sending seek Command for Consumer - " <<
getConsumerId() << ", requestId - "
<< requestId);
+ auto chunkMessageIdImpl =
std::dynamic_pointer_cast<ChunkMessageIdImpl>(msgId.impl_);
Future<Result, ResponseData> future =
- cnx->sendRequestWithId(Commands::newSeek(consumerId_, requestId,
msgId), requestId);
+ (chunkMessageIdImpl != nullptr)
+ ? cnx->sendRequestWithId(
+ Commands::newSeek(consumerId_, requestId,
+
chunkMessageIdImpl->getFirstChunkMessageIdImpl().ledgerId_,
+
chunkMessageIdImpl->getFirstChunkMessageIdImpl().entryId_),
+ requestId)
+ : cnx->sendRequestWithId(Commands::newSeek(consumerId_,
requestId, msgId), requestId);
Review comment:
I think we can eliminate the following overload of `newSeek`.
```c++
SharedBuffer newSeek(uint64_t consumerId, uint64_t requestId, const
MessageId& messageId);
```
Just get the ledger id and entry id here and use the newly added overload.
```c++
const auto ledgerId = (chunkMessageIdImpl ?
chunkMessageIdImpl->getFirstChunkMessageIdImpl().ledgerId_
: msgId.ledgerId());
const auto entryId = (chunkMessageIdImpl ?
chunkMessageIdImpl->getFirstChunkMessageIdImpl().ledgerId_
: msgId.entryId());
Future<Result, ResponseData> future =
cnx->sendRequestWithId(Commands::newSeek(consumerId_, requestId,
ledgerId, entryId), requestId);
```
----
But I think a better solution is checking the type of `MessageIdImpl` in
`Commands::newSeek` like:
```c++
const auto msgIdImpl = messageId.impl_;
const auto chunkMessageIdImpl =
std::dynamic_pointer_cast<ChunkMessageIdImpl>(msgIdImpl);
if (chunkMessageIdImpl) {
const auto& firstMsgId =
chunkMessageIdImpl->getFirstChunkMessageIdImpl();
messageIdData.set_ledgerid(firstMsgId.ledgerId_);
messageIdData.set_entryid(firstMsgId.entryId_);
} else {
messageIdData.set_ledgerid(msgIdImpl->ledgerId_);
messageIdData.set_entryid(msgIdImpl->entryId_);
}
```
--
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]