liangyepianzhou commented on code in PR #21166: URL: https://github.com/apache/pulsar/pull/21166#discussion_r1325305404
########## pip/pip-302.md: ########## @@ -0,0 +1,89 @@ +# Background Knowledge + +The TableView interface provides a convenient way to access data in a compacted topic by offering a continuously updated key-value map view. It operates on messages with keys and ignores those without keys. + +By utilizing the TableView, Pulsar clients can retrieve all message updates from a specific topic and create a map that contains the latest values for each key. This map can be used to establish a local cache of data. Additionally, clients can register consumers with the TableView and specify a listener to scan the map and receive notifications whenever new messages are received. This functionality enables event-driven applications and message monitoring. + +For more detailed information about the TableView, please refer to the [Pulsar documentation](https://pulsar.apache.org/docs/next/concepts-clients/#tableview). + +# Motivation + +In the context of utilizing the TableView component, there are instances where we aspire to consistently retrieve the most up-to-date value associated with a given key. To accomplish this, we can employ an API that allows us to wait until all data has been fully retrieved before accessing the value corresponding to the desired key. +# Goals + +## In Scope + +The proposed changes aim to add a new API that triggers the reading of all existing messages, updates the TableView, and waits for the read operation to complete. This will be achieved by introducing the `readAllExistingMessages()` method. + +## Out of Scope + +No out-of-scope items have been identified at this time. + +# High-Level Design + +The high-level design involves the addition of a new API method called `readAllExistingMessages()`. This method will be responsible for initiating the process of reading all existing messages, updating the TableView, and waiting for the read operation to complete. + +# Detailed Design + +## Design & Implementation Details + +The `readAllExistingMessages()` method will be implemented as follows: + +```java +@Override +public CompletableFuture<Void> readAllExistingMessages() { Review Comment: Why isn't this an issue with the existing implementation? If there are a large number of producers sending messages to a single topic, then the delay in building the TableView for this topic could be very large, and in extreme cases, it may never be completed. -- 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]
