Repository navigation
Closed
Description
Search before asking
- I searched in the issues and found nothing similar.
Version
Client 3.5.0
Minimal reproduce step
Create a main.cc
#include <chrono>
#include <pulsar/Client.h>
using namespace pulsar;
int main(int argc, char *argv[]) {
Client client{"pulsar://localhost:6650"};
std::string topic = (argc > 1) ? argv[1] : "my-topic";
Producer producer;
if (auto result = client.createProducer(topic, producer);
result != ResultOk) {
std::cerr << "Failed to create producer: " << result << std::endl;
return 1;
}
producer.send(MessageBuilder().setContent("msg-0").build());
Reader reader;
if (auto result =
client.createReader(topic, MessageId::latest(), {}, reader);
result != ResultOk) {
std::cerr << "Failed to create reader: " << result << std::endl;
return 2;
}
using namespace std::chrono;
reader.seek(
duration_cast<milliseconds>(system_clock::now().time_since_epoch())
.count());
bool hasMessage;
if (auto result = reader.hasMessageAvailable(hasMessage);
result != ResultOk) {
std::cerr << "hasMessageAvailable failed: " << result << std::endl;
return 3;
}
std::cout << hasMessage << std::endl;
return 0;
}Key point: the start position must be latest for Reader.
On macOS m1, install the the macos-arm64.zip and build with those artifacts.
curl -O -L https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.5.0/macos-arm64.zip
unzip -q macos-arm64.zip
g++ main.cc -std=c++17 -I ./include -L ./lib -Wl,-rpath ./lib -lpulsar
./a.outWhat did you expect to see?
Outputs (ignore the outputs from the library):
1
What did you see instead?
The output should be 0 like the behavior with 3.4.2
curl -O -L https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.4.2/macos-arm64.zip
unzip -q macos-arm64.zip
g++ main.cc -std=c++17 -I ./include -L ./lib -Wl,-rpath ./lib -lpulsar
./a.outOutputs:
0
Anything else?
No response
Are you willing to submit a PR?
- I'm willing to submit a PR!
Metadata
Metadata
Assignees
Labels
No labels
Activity
Fix wrong results of hasMessageAvailable and readNext after seeking b…
Fix wrong results of hasMessageAvailable and readNext after seeking b…
Fix wrong results of hasMessageAvailable and readNext after seeking b…