Skip to content

[Doc] Include ReaderListener example in Reader interface  #19728

@paulkmoore

Description

@paulkmoore

Search before asking

  • I searched in the 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.

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

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

Labels

Staledoc-requiredYour PR changes impact docs and you will update later.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions