com-poorbar commented on a change in pull request #12792:
URL: https://github.com/apache/pulsar/pull/12792#discussion_r753329979



##########
File path: 
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/ConsumerEventListener.java
##########
@@ -49,4 +50,17 @@
      */
     void becameInactive(Consumer<?> consumer, int partitionId);
 
+
+    /**
+     * Notified when the consumer key_shared_rule is changed.
+     *
+     * @param consumer
+     *            the consumer that originated the event
+     * @param keyPredicate
+     *            Determine whether the key will be consumed by {@param 
consumer}
+     */
+    default void keySharedRuleChanged(Consumer<?> consumer, Predicate<String> 
keyPredicate) {

Review comment:
       ah ah ha!.  Sorry. It looks like "I misunderstood the need".  Let me 
explain "why I did that"
   
   The `keyPredicate` will be useful in this case : [At #6555, User want know 
`when a key will be consumed by current consumer` 
](https://github.com/apache/pulsar/issues/6555#issuecomment-735347905). 
   
   For example: 
   1. When user has one consumer: 
   goods event queue(key is goods_id)  -->  [1~65535] ---> consumer_01 --> user 
can cache all goods object in local cache
   2. When user add other consumer
   goods event queue(key is goods_id) -->  [[1~32768]]() --> consumer_01 ---> 
user can cache half goods object in local cache( logic node 1 )
   goods event queue(key is goods_id)  -->  [32768~65535] --> consumer_01 --> 
user can cache other half goods object in local cache( logic node 2)
   
   My thought was: 
   
   In `Mode-failover` message sharding by patition, `ConsumerEventListener` 
tell user "witch message will be consumed by current consumer".
   
   In `Mode-Key_Shared` message sharding by key, `ConsumerEventListener` tell 
user "witch message will be consumed by current consumer" too.
   
   How am I supposed to understand "latest key hash range" ? `hash range` 
defined in `HashRangeAutoSplitStickyKeyConsumerSelector` only, but in other 
implements `[HashRangeExclusiveStickyKeyConsumerSelector, 
ConsistentHashingStickyKeyConsumerSelector]` has not defiend the `hash range`




-- 
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]


Reply via email to