BewareMyPower commented on issue #9796:
URL: https://github.com/apache/pulsar/issues/9796#issuecomment-800772931
The problem is how to reproduce it.
To reproduce `ProducerQueueIsFull`, I tried to set the max pending messages
to 1.
```c++
ProducerConfiguration producerConf;
producerConf.setMaxPendingMessages(1);
Producer producer;
Result result = client.createProducer("my-topic", producerConf,
producer);
```
And remove the `sleep` call in the code before. The example program ran well
and no segmentation fault happens. There're 79 messages that were sent
successfully and 9921 messages that encountered `ProducerQueueIsFull` in an
example run.
If you want to avoid this error, you can set `blockingIsFull` true.
```c++
producerConf.setBlockIfQueueFull(true);
```
And you can see if the segmentation fault happen again with the config.
BTW, currently the `sendAsync` has no returned value, so if you want to
check `ProducerQueueIsFull` immediately, it may need some tricks like
```c++
Result immediateResult = ResultOk;
producer.sendAsync(msg, [&immediateResult](Result result, const
MessageId& id) {
immediateResult = result;
if (immediateResult != ResultProducerQueueIsFull) {
callback(result, id);
}
});
if (immediateResult == ResultProducerQueueIsFull) {
// TODO: do something
}
```
Though it looks a little ugly.
----------------------------------------------------------------
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]