kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From BigData dev <bigdatadev...@gmail.com>
Subject Re: any way to manually assign listeners to kafka partitions ?
Date Sat, 25 Mar 2017 17:45:14 GMT
There is a method is consumer is used for getting all partitions for a topic
List
<http://docs.oracle.com/javase/7/docs/api/java/util/List.html?is-external=true>
<PartitionInfo
<https://kafka.apache.org/0100/javadoc/org/apache/kafka/common/PartitionInfo.html>
> *partitionsFor
<https://kafka.apache.org/0100/javadoc/org/apache/kafka/clients/consumer/Consumer.html#partitionsFor(java.lang.String)>*
(String
<http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true>
 topic)

And next assign method can be used to assign the required partitions for
that consumer
void *assign
<https://kafka.apache.org/0100/javadoc/org/apache/kafka/clients/consumer/Consumer.html#assign(java.util.Collection)>*
(Collection
<http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true>
<TopicPartition
<https://kafka.apache.org/0100/javadoc/org/apache/kafka/common/TopicPartition.html>
> partitions)
So, in each thread you can use these methods, and do the needful.

Thanks,
Bharat

On Sat, Mar 25, 2017 at 10:35 AM, Laxmi Narayan <nit.dgp673@gmail.com>
wrote:

> Hi ,
> Is there anyway to get the list of all paritions and assign them to
> individual java threads for constantly listening ?
>
> Keep learning keep moving .....
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message