RobertIndie commented on code in PR #16943:
URL: https://github.com/apache/pulsar/pull/16943#discussion_r939806303
##########
pulsar-client-cpp/tests/ReaderTest.cc:
##########
@@ -579,3 +579,30 @@ TEST(ReaderTest, testHasMessageAvailableWhenCreated) {
EXPECT_FALSE(hasMessageAvailable);
client.close();
}
+
+TEST(ReaderTest, testReceiveAfterSeek) {
+ Client client(serviceUrl);
+ const std::string topic = "reader-test-receive-after-seek-" +
std::to_string(time(nullptr));
+
+ Producer producer;
+ ASSERT_EQ(ResultOk, client.createProducer(topic, producer));
+
+ MessageId seekMessageId;
+ for (int i = 0; i < 5; i++) {
+ MessageId messageId;
+ producer.send(MessageBuilder().setContent("msg-" +
std::to_string(i)).build(), messageId);
+ if (i == 3) {
+ seekMessageId = messageId;
+ }
+ }
+
+ Reader reader;
+ ASSERT_EQ(ResultOk, client.createReader(topic, MessageId::latest(), {},
reader));
+
+ reader.seek(seekMessageId);
+
+ bool hasMessageAvailable;
+ ASSERT_EQ(ResultOk, reader.hasMessageAvailable(hasMessageAvailable));
Review Comment:
Not really. The connection will be reconnected after the seek operation.
I have added a test `testGetLastMessageIdBlockWhenConnectionDisconnected` to
test it more rigorous. PTAL. Thanks.
--
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]