sijie commented on issue #3733: support Pattern subscribe in kafka compat client
URL: https://github.com/apache/pulsar/issues/3733#issuecomment-471242118
 
 
   @liketic 
   
   I see your point now. if we don't care about notifying 
`ConsumerRebalanceListener`, then we can just use `#topicsPattern(pattern)`.
   
   so I would suggest introducing a `TopicPartitionListener` in pulsar consumer 
to receive the partitions. so pulsar will manage notifying the topic 
partitions, instead of us doing this in kafka wrapper. so the implementation in 
kafka wrapper would be something like
   
   ```
       @Override
       public void subscribe(Pattern pattern, ConsumerRebalanceListener 
callback) {
           ConsumerBuilder<byte[]> consumerBuilder = 
PulsarConsumerKafkaConfig.getConsumerBuilder(client, properties);
           consumerBuilder.subscriptionType(SubscriptionType.Failover);
           consumerBuilder.messageListener(this);
           consumerBuilder.subscriptionName(groupId);
           consumerBuilder.topicsPattern(pattern);
           consumerBuilder.topicsListener(topicPartitions -> {
                  callback.onPartitionsAssigned(topicPartitions);
           });
           try {
               consumerBuilder.subscribe();
           } catch (Exception ex) {
               throw new RuntimeException(ex);
           }
       }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to