BewareMyPower commented on issue #9796:
URL: https://github.com/apache/pulsar/issues/9796#issuecomment-790669493
What is your `MAX_COUNT` used for? Did you mean running
```
Message msg = MessageBuilder().setContent("content").setProperty("x",
"1").build();
producer.sendAsync(msg, callback);
std::this_thread::sleep_for(std::chrono::seconds(1));
```
for 10000 times? Sleeping for 10000 seconds is too long, I changed it to 10
milliseconds and rerun in my local environment. No segmentation fault happened.
```c++
#include <iostream>
#include <thread>
#include <pulsar/Client.h>
#include <lib/LogUtils.h>
DECLARE_LOG_OBJECT()
using namespace pulsar;
void callback(Result code, const MessageId& msgId) {
LOG_INFO("Received code: " << code << " -- MsgID: " << msgId);
}
int main() {
Client client("pulsar://localhost:6650");
Producer producer;
Result result = client.createProducer("my-topic", producer);
if (result != ResultOk) {
LOG_ERROR("Error creating producer: " << result);
return -1;
}
// Send asynchronously
for (int i = 0; i < 10000; i++) {
Message msg =
MessageBuilder().setContent("content").setProperty("x", "1").build();
producer.sendAsync(msg, callback);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
client.close();
return 0;
}
```
BTW, did you use the default logger which prints logs to `stdout` or your
self-defined logger?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]