Skip to content
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

[improve][client] PIP-224: Add getLastMessageIds API to deprecate getLastMessageId #25

Closed
wants to merge 4 commits into from

Conversation

BewareMyPower
Copy link
Owner

Master Issue: apache#18616

Fixes apache#4940

NOTE: This implementation is different from the original design of PIP-224 that the method name is getLastMessageIds instead of getLastTopicMessageId.

Motivation

When a multi-topics consumer calls getLastMessageId, a MultiMessageIdImpl instance will be returned. It contains a map of the topic name and the latest message id of the topic. However, the MultiMessageIdImpl cannot be used in any place of the API that accepts a MessageId because all methods of the MessageId interface are not implemented, including compareTo and toByteArray.

Therefore, users cannot do anything on such a MessageId implementation except casting MessageId to MultiMessageIdImpl and get the internal map.

Modifications

  • Throw an exception when calling getLastMessageId on a multi-topics consumer instead of returning a MultiMessageIdImpl.
  • Remove the MultiMessageIdImpl implementation and its related tests.
  • Add the getLastMessageIds methods to Consumer. It returns a list of TopicMessageId instances, each of them represents the last message id of the owner topic.
  • Mark the getLastMessageId API as deprecated.

Verifications

  • Modify the TopicsConsumerImplTest#testGetLastMessageId to test the getLastMessageIds for a multi-topics consumer.
  • Modify the TopicReaderTest#testHasMessageAvailable to test the getLastMessageIds for a single topic consumer.

…LastMessageId

Master Issue: apache#18616

Fixes apache#4940

NOTE: This implementation is different from the original design of
PIP-224 that the method name is `getLastMessageIds` instead of
`getLastTopicMessageId`.

### Motivation

When a multi-topics consumer calls `getLastMessageId`, a
`MultiMessageIdImpl` instance will be returned. It contains a map of the
topic name and the latest message id of the topic. However, the
`MultiMessageIdImpl` cannot be used in any place of the API that accepts
a `MessageId` because all methods of the `MessageId` interface are not
implemented, including `compareTo` and `toByteArray`.

Therefore, users cannot do anything on such a `MessageId` implementation
except casting `MessageId` to `MultiMessageIdImpl` and get the internal
map.

### Modifications

- Throw an exception when calling `getLastMessageId` on a multi-topics
  consumer instead of returning a `MultiMessageIdImpl`.
- Remove the `MultiMessageIdImpl` implementation and its related tests.
- Add the `getLastMessageIds` methods to `Consumer`. It returns a list
  of `TopicMessageId` instances, each of them represents the last
  message id of the owner topic.
- Mark the `getLastMessageId` API as deprecated.

### Verifications

- Modify the `TopicsConsumerImplTest#testGetLastMessageId` to test the
  `getLastMessageIds` for a multi-topics consumer.
- Modify the `TopicReaderTest#testHasMessageAvailable` to test the
  `getLastMessageIds` for a single topic consumer.
@BewareMyPower BewareMyPower force-pushed the bewaremypower/pip-224-get-last-msg-id branch 2 times, most recently from b6e118a to fd129bb Compare April 10, 2023 13:08
@BewareMyPower BewareMyPower force-pushed the bewaremypower/pip-224-get-last-msg-id branch from fd129bb to 0960047 Compare April 10, 2023 13:09
Co-authored-by: Baodi Shi <[email protected]>
@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions bot added the Stale label May 11, 2023
@BewareMyPower BewareMyPower deleted the bewaremypower/pip-224-get-last-msg-id branch March 5, 2024 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serialization and Deserialization for MultiMessageIdImpl
1 participant