Shoothzj commented on issue #11783:
URL: https://github.com/apache/pulsar/issues/11783#issuecomment-909347986
I just figure out why, because the client code retry to send messages when
exception occurred to avoid network "Jitter"(Translate on google). the sample
code are like this
```java
String topic = "test";
PulsarClient pulsarClient = PulsarClient.builder()
.serviceUrl("http://127.0.0.1:8080")
.build();
ProducerBuilder<String> producerBuilder =
pulsarClient.newProducer(Schema.STRING).enableBatching(true);
Producer<String> producer = producerBuilder.topic(topic).create();
final TypedMessageBuilder<String> stringTypedMessageBuilder =
producer.newMessage();
final TypedMessageBuilder<String> value =
stringTypedMessageBuilder.key("1").value("2");
final CompletableFuture<MessageId> completableFuture =
value.sendAsync();
completableFuture.exceptionally(throwable -> {
producer.sendAsync("xxxx");
return null;
});
```
The `exceptionally` is called from `ProducerImpl.failPendingMessages`'s
forEachLoop, and `sendAsync` will add messages to `pendingMessages`, then the
error ocurred.
I have a question. Should we allow to retry on `exceptionally` callback or
prohibit usage like that ?
@315157973 @eolivelli @merlimat , 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]