-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Broker]Reset cursor with a non-exists position #6120
Conversation
@yjshen this looks good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. please go ahead to add tests. and maybe add docs also?
+1 |
Test added. PTAL, thanks! |
The previous implementation doesn't match the Rest API documentation: |
`ManagedCursorImpl.asyncResetCursor` is used in three kinds of circumstances: - REST API: create a subscription with messageId. Per the document: Reset subscription to message position closest to given position. - REST API: reset subscription to a given position: Per the document: Reset subscription to message position closest to given position. - Consumer seek command. In all the cases above, when the user provides a MessageId, we should make the best effort to find the closest position, instead of throwing an InvalidCursorPosition Exception. This is because if a user provids an invalid position, it's not possible for he or she gets a valid position, since ledger ids for a given topic may not be continuous and only brokers are aware of the order. Therefore, we should avoid throw invalid cursor position but find the nearest position and do the reset stuff.
`ManagedCursorImpl.asyncResetCursor` is used in three kinds of circumstances: - REST API: create a subscription with messageId. Per the document: Reset subscription to message position closest to given position. - REST API: reset subscription to a given position: Per the document: Reset subscription to message position closest to given position. - Consumer seek command. In all the cases above, when the user provides a MessageId, we should make the best effort to find the closest position, instead of throwing an InvalidCursorPosition Exception. This is because if a user provids an invalid position, it's not possible for he or she gets a valid position, since ledger ids for a given topic may not be continuous and only brokers are aware of the order. Therefore, we should avoid throw invalid cursor position but find the nearest position and do the reset stuff. (cherry picked from commit d2f37a7)
`ManagedCursorImpl.asyncResetCursor` is used in three kinds of circumstances: - REST API: create a subscription with messageId. Per the document: Reset subscription to message position closest to given position. - REST API: reset subscription to a given position: Per the document: Reset subscription to message position closest to given position. - Consumer seek command. In all the cases above, when the user provides a MessageId, we should make the best effort to find the closest position, instead of throwing an InvalidCursorPosition Exception. This is because if a user provids an invalid position, it's not possible for he or she gets a valid position, since ledger ids for a given topic may not be continuous and only brokers are aware of the order. Therefore, we should avoid throw invalid cursor position but find the nearest position and do the reset stuff. (cherry picked from commit d2f37a7)
`ManagedCursorImpl.asyncResetCursor` is used in three kinds of circumstances: - REST API: create a subscription with messageId. Per the document: Reset subscription to message position closest to given position. - REST API: reset subscription to a given position: Per the document: Reset subscription to message position closest to given position. - Consumer seek command. In all the cases above, when the user provides a MessageId, we should make the best effort to find the closest position, instead of throwing an InvalidCursorPosition Exception. This is because if a user provids an invalid position, it's not possible for he or she gets a valid position, since ledger ids for a given topic may not be continuous and only brokers are aware of the order. Therefore, we should avoid throw invalid cursor position but find the nearest position and do the reset stuff. (cherry picked from commit d2f37a7)
`ManagedCursorImpl.asyncResetCursor` is used in three kinds of circumstances: - REST API: create a subscription with messageId. Per the document: Reset subscription to message position closest to given position. - REST API: reset subscription to a given position: Per the document: Reset subscription to message position closest to given position. - Consumer seek command. In all the cases above, when the user provides a MessageId, we should make the best effort to find the closest position, instead of throwing an InvalidCursorPosition Exception. This is because if a user provids an invalid position, it's not possible for he or she gets a valid position, since ledger ids for a given topic may not be continuous and only brokers are aware of the order. Therefore, we should avoid throw invalid cursor position but find the nearest position and do the reset stuff.
ManagedCursorImpl.asyncResetCursor
is used in three kinds of circumstances:In all the cases above, when the user provides a MessageId, we should make the best effort to find the closest position, instead of throwing an InvalidCursorPosition Exception.
This is because if a user provids an invalid position, it's not possible for he or she gets a valid position, since ledger ids for a given topic may not be continuous and only brokers are aware of the order. Therefore, we should avoid throw invalid cursor position but find the nearest position and do the reset stuff.