-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PIP 101] Add seek by index feature for consumer #12234
Comments
Let's move the discussion here. @MarvinCai
I think it's a document issue. If we've documented well for the pulsar/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Message.java Lines 274 to 282 in 879e93d
(Though I think this doc is not well. We should make it clear that which configs should be configured in broker.) Similarly, The current seek operation by message id also has some restrictions. pulsar/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Consumer.java Lines 586 to 587 in 879e93d
In conclusion, it provides a solution for users that are eager for message count based seek semantics. At the same time, it doesn't affect existing APIs. |
IMHO, It's quite common that part of the features in client depends on some configurations in server, eg authentication, authorization, transaction. All of these features are not enabled by default, and users have to change the broke configurations to use these features with client. |
I am fine with this new feature, mostly because we added "Optional getIndex(); " in the Message API. We could also think to enable the 'index' (AppendIndexMetadataInterceptor ) by default if the impact on the data size is negligible |
it should be better that the Consumer receives a meaningful error in case that the value is not available because AppendIndexMetadataInterceptor is not available. |
I have assigned PIP101 and added the link in the Wiki page |
The issue had no activity for 30 days, mark with Stale label. |
Closing this for now, as there are not enough votes. |
I am interested in this, as it is helping people transitioning from Kafka. |
Motivation
Currently we can reset the read position of a cursor by message id or timestamp. Since we formerly introduced index in broker metadata since 2.8.0, reset cursor by index is very helpful in other protocol handler (KoP or RoP).
Goal
Add seek by index feature for consumer.
API Changes
Add following interface in
org.apache.pulsar.client.api.Consumer
Here is the docs for this new interface.
Reset the subscription associated with this consumer to a specific message index.
For example, giving the index of message in this topic is in range [A, B), where A <= B;
Note: "org.apache.pulsar.common.intercept.AppendIndexMetadataInterceptor" must be added to "brokerEntryMetadataInterceptors" in broker configuration to enable index meta in broker.
Implementation
For client-broker communication, we can reuse the old CommandSeek, which is used for
seek(messageId)
andseek(timestamp)
. Add an optional field "index" for this interface.In broker, the implementation for seek by index is basically the same as seek by timestamp. The key is to find the messageId with the giving index. A new class PersistentMessageFinderByIndex is introduced to do this. The difference between PersistentMessageFinderByIndex and origin PersistentMessageFinder is that, PersistentMessageFinderByIndex use BrokerEntryMetadata#index of the searching message instead of BrokerEntryMetadata#brokerTimestamp. Once we find the messageId, we can reset the subscription with
PersistentSubscription#resetCursor
.Reject Alternatives
No alternatives yet.
The text was updated successfully, but these errors were encountered: