I believe I already answered your question in another channel, but just to follow up in this thread in case anyone else is interested in the answer:
You can override the *ConsumerPartitionAssignor.onAssignment(Assignment, ConsumerGroupMetadata)* method to get an update on the currently assigned partitions after each rebalance. The *Assignment* parameter contains two fields: the assigned partitions, and the serialized assignment userdata, if any. On Sat, Mar 6, 2021 at 6:34 AM Mazen Ezzeddine < mazen.ezzedd...@etu.univ-cotedazur.fr> wrote: > Hi all, > > I am implementing a custom consumers to topics/partitions assignor in > Kafka. To this end, I am overriding the AbstractPartitionAssignor which in > turn implements the ConsumerPartitionAssignor interface. > > As part of the custom assignor, I want to send a single (float) > information about each partition of each topic that the consumer subscribes > to. > > I am aware that I can send custom data to the assignor by overriding the > default method > ByteBuffer subscriptionUserData(Set<String> topics) . > > However, the issue is that from the method signature above I can not get > the list of partitions assigned to the underlined consumer for each of the > topics that the consumer registers for. > > On the other hand, I can see that the subscription class sent by each of > the consumers to the group coordinator has list of the owned partitions per > consumer. > public static final class Subscription { > private final List<String> topics; > private final ByteBuffer userData; > private final List<TopicPartition> ownedPartitions; > private Optional<String> groupInstanceId; > > > Any hint on how I can send custom per partition data to the group > coordinator through the method ByteBuffer subscriptionUserData(Set<String> > topics), or using any other way that relies only on the kafka public APIs. > > Thank you. > >