paulkmoore opened a new issue, #19728:
URL: https://github.com/apache/pulsar/issues/19728

   ### Search before asking
   
   - [X] I searched in the [issues](https://github.com/apache/pulsar/issues) 
and found nothing similar.
   
   
   ### What issue do you find in Pulsar docs?
   
   I think it would be useful to introduce the ReaderListener in the [Reader 
interface 
introduction](https://pulsar.apache.org/docs/2.11.x/concepts-clients/#reader-interface).
   
   Whilst there is obviously a balance here, I think most (especially new) 
users would want to understand that there is a better way of processing 
messages than the documented `while(true)` loop.
   
   
   
   ### What is your suggestion?
   
   I would add something like the following:
   
   Messages can be processed by registering an implementation of a 
[ReaderInterface](https://pulsar.apache.org/api/client/2.11.x/org/apache/pulsar/client/api/ReaderListener.html)
 as follows:
   
   ```
   Reader<byte[]> reader = pulsarClient.newReader()
       .topic(topic)
       .startMessageId(MessageId.latest)
       .readerListener((ReaderListener<byte[]>) (reader, msg) -> {
         // Process the message  
       })
       .create();
   ```
   
   ### Any reference?
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [X] I'm willing to submit a PR!


-- 
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]

Reply via email to