org.springframework.integration.kafka.core
Interface ConnectionFactory

All Known Implementing Classes:
DefaultConnectionFactory

public interface ConnectionFactory

Creates Kafka connections and retrieves metadata for topics and partitions.


Method Summary
 Connection connect(BrokerAddress brokerAddress)
          Create a connection to a Kafka broker, caching it internally
 BrokerAddress getLeader(Partition partition)
          Return the leader for a single partition
 java.util.Map<Partition,BrokerAddress> getLeaders(java.lang.Iterable<Partition> partitions)
          Retrieve the leaders for a set of partitions.
 java.util.Collection<Partition> getPartitions(java.lang.String topic)
          Retrieves the partitions of a given topic
 void refreshMetadata(java.util.Collection<java.lang.String> topics)
          Refresh the cached metadata (i.e.
 

Method Detail

connect

Connection connect(BrokerAddress brokerAddress)
Create a connection to a Kafka broker, caching it internally

Parameters:
brokerAddress - a broker address
Returns:
a working connection

getLeaders

java.util.Map<Partition,BrokerAddress> getLeaders(java.lang.Iterable<Partition> partitions)
Retrieve the leaders for a set of partitions.

Parameters:
partitions - whose leaders are queried
Returns:
the broker associated with the provided topic and partition

getLeader

BrokerAddress getLeader(Partition partition)
Return the leader for a single partition

Parameters:
partition - the partition whose leader is queried
Returns:
the leader's address

refreshMetadata

void refreshMetadata(java.util.Collection<java.lang.String> topics)
Refresh the cached metadata (i.e. leader topology and partitions). To be called when the topology changes are detected (i.e. brokers leave and/or partition leaders change) and that results in fetch errors, for instance.

Parameters:
topics - the topics for which to refresh the leaders

getPartitions

java.util.Collection<Partition> getPartitions(java.lang.String topic)
Retrieves the partitions of a given topic

Parameters:
topic - the topic to query for
Returns:
a list of partitions