yitian108 opened a new issue #9796:
URL: https://github.com/apache/pulsar/issues/9796
#### Expected behavior
When I try to use c++ to test the pulsar program with asyn producer, I
expect the program could run well like sync mode
Tell us what should happen
However, I encounter the segment fault,
#### Actual behavior
2021-03-04 15:18:28.363 INFO [139953628752320] ConnectionPool:85 | Created
connection for pulsar://localhost:6650
2021-03-04 15:18:28.364 INFO [139953598220032] ClientConnection:353 |
[127.0.0.1:40292 -> 127.0.0.1:6650] Connected to broker
2021-03-04 15:18:28.391 INFO [139953598220032] HandlerBase:54 |
[persistent://ABC/abc, ] Getting connection from pool
2021-03-04 15:18:28.399 INFO [139953598220032] ProducerImpl:170 |
[persistent://ABC/abc, ] Created producer on broker [127.0.0.1:40292 ->
127.0.0.1:6650]
Segmentation fault (core dumped)
Tell us what happens instead
Hopefully, there is no fault as sync mode
#### Steps to reproduce
1. write the program in terminal as following (file: asyncProducer.cc)
`#include <iostream>
#include <pulsar/Client.h>
#include <lib/LogUtils.h>
#include <stdio.h>
#include <thread>
#define MAX_COUNT 10000
DECLARE_LOG_OBJECT()
using namespace pulsar;
void callback(Result code, const MessageId& msgId)
{
std::cout << "Received code: " << code << " -- MsgID: " << msgId;
}
int main() {
Client client("pulsar://localhost:6650");
Producer producer;
Result result = client.createProducer("persistent://ABC/abc", producer);
if (result != ResultOk) {
LOG_ERROR("Error creating producer: " << result);
return -1;
}
while (true) {
Message msg =
MessageBuilder().setContent("content").setProperty("x", "1").build();
producer.sendAsync(msg, callback);
std::this_thread::sleep_for(std::chrono::seconds(1));
}
client.close();
}
`
2. compile the program with 'g++ --std=c++11 asyncProducer.cc -o
asyncProducer -g -IXXX/pulsar-2.7/include -LXXX/pulsar-2.7/lib -lpulsar',
please note the XXX should be the directory which installation of pulsar 2.7
3. ./asyncProducer
#### System configuration
**Pulsar version**: 2.7
----------------------------------------------------------------
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]