You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/12/06 09:03:15 UTC

[GitHub] [pulsar] BewareMyPower commented on issue #5662: [doc] API documentation doesn't describe behaviour of async callbacks

BewareMyPower commented on issue #5662:
URL: https://github.com/apache/pulsar/issues/5662#issuecomment-1338994355

   @tisonkun The behavior is expected. The behavior is similar in Java client. The callback is executed by the internal executor of the pulsar-client library. The thread is different from the main thread.
   
   ```java
           @Cleanup final var client = PulsarClient.builder().serviceUrl(Config.BROKER_URL).build();
           System.out.println(Thread.currentThread().getName());
           client.newProducer(Schema.STRING)
                   .topic("my-topic")
                   .create()
                   .sendAsync("hello")
                   .thenAccept(id -> System.out.println(Thread.currentThread().getName() + " " + id))
                   .get();
   ```
   
   Outputs:
   
   ```
   main
   pulsar-client-io-1-1 16:0:-1:0
   ```
   
   > I cannot see it documented anywhere whether the callbacks occur in a different thread
   
   I'm not sure if it's worth documenting. Should we assume the callback is executed in the caller's thread without any explicit explanation?


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org