-
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
[C++] Support setting priority for the consumer #12076
Conversation
There's something wrong with vcpkg build on Windows currently so that the I'll push a fix soon. |
Please rebase to master to fix the broken CI. |
ac383c6
to
cb4a41e
Compare
PTAL @BewareMyPower, running the workflows require approval. |
It seems that |
Yeah, it's a flaky test but now it doesn't fail frequently. You can comment |
OK, got it. Thanks. |
…13883) In C++ client, there is a corner case that when a reader's start message ID is the last message of a topic, `hasMessageAvailable` returns true. However, it should return false because the start message ID is exclusive and in this case `readNext` would never return a message unless new messages arrived. The current C++ implementation of `hasMessageAvailable` is from long days ago and has many problems. So this PR migrates the Java implementation of `hasMessageAvailable` to C++ client. Since after the modifications we need to access `startMessageId` in `hasMessageAvailable`, which is called in a different thread from `connectionOpened` that might modify `startMessageId`. We use a common mutex `mutexForMessageIds` to protect the access to `lastDequedMessageId_` and `lastMessageIdInBroker_`. To fix the original tests when `startMessageId` is latest, this PR adds a `GetLastMessageIdResponse` as the response of `GetLastMessageId` request. The `GetLastMessageIdResponse` contains the `consumer_mark_delete_position` introduced from #9652 to compare with `last_message_id` when `startMessageId` is latest. This change added tests `ReaderTest#testHasMessageAvailableWhenCreated` and `MessageIdTest# testCompareLedgerAndEntryId`. (cherry picked from commit e50493e) Fix the conflicts by: - Remove ReaderImpl::getLastMessageIdAsync introduced from #11723 - Remove getPriorityLevel() method introduced from #12076 - Revert changes of registerConsumer from #12118 - Remove new fields introduced from #13627
* [C++] Support setting priority for the consumer * Fixed formatting * Fixed code style Co-authored-by: sunhongyi <sunhongyi@tencent.com>
Motivation
#165 added support for dispatching message based on consumer priority. However, for C++ client, there is no way to set such priority on
ConsumerConfiguration
. This PR is to support setting priority for the consumer in C++ client.Modifications
getPriorityLevel
andsetPriorityLevel
methods inConsumerConfiguration
Commands::newSubscribe
to add additional parameterpriority_level
with default value 0Verifying this change
This change added tests and can be verified as follows:
ConsumerConfiguration::getPriorityLevel
andConsumerConfiguration::setPriorityLevel
inConsumerConfigurationTest
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changes