org.springframework.integration.kafka.core
Class DefaultConnectionFactory

java.lang.Object
  extended by org.springframework.integration.kafka.core.DefaultConnectionFactory
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, ConnectionFactory

public class DefaultConnectionFactory
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean, ConnectionFactory, org.springframework.beans.factory.DisposableBean

Default implementation of ConnectionFactory


Field Summary
static com.gs.collections.api.block.predicate.Predicate<kafka.javaapi.TopicMetadata> errorlessTopicMetadataPredicate
           
 
Constructor Summary
DefaultConnectionFactory(Configuration configuration)
           
 
Method Summary
 void afterPropertiesSet()
           
 Connection connect(BrokerAddress brokerAddress)
          Create a connection to a Kafka broker, caching it internally
 void destroy()
           
 Configuration getConfiguration()
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errorlessTopicMetadataPredicate

public static final com.gs.collections.api.block.predicate.Predicate<kafka.javaapi.TopicMetadata> errorlessTopicMetadataPredicate
Constructor Detail

DefaultConnectionFactory

public DefaultConnectionFactory(Configuration configuration)
Method Detail

getConfiguration

public Configuration getConfiguration()

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

destroy

public void destroy()
             throws java.lang.Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
java.lang.Exception

getLeaders

public java.util.Map<Partition,BrokerAddress> getLeaders(java.lang.Iterable<Partition> partitions)
Description copied from interface: ConnectionFactory
Retrieve the leaders for a set of partitions.

Specified by:
getLeaders in interface ConnectionFactory
Parameters:
partitions - whose leaders are queried
Returns:
the broker associated with the provided topic and partition
See Also:
ConnectionFactory.getLeaders(Iterable)

getLeader

public BrokerAddress getLeader(Partition partition)
Description copied from interface: ConnectionFactory
Return the leader for a single partition

Specified by:
getLeader in interface ConnectionFactory
Parameters:
partition - the partition whose leader is queried
Returns:
the leader's address
See Also:
ConnectionFactory.getLeader(Partition)

connect

public Connection connect(BrokerAddress brokerAddress)
Description copied from interface: ConnectionFactory
Create a connection to a Kafka broker, caching it internally

Specified by:
connect in interface ConnectionFactory
Parameters:
brokerAddress - a broker address
Returns:
a working connection
See Also:
ConnectionFactory.connect(BrokerAddress)

refreshMetadata

public void refreshMetadata(java.util.Collection<java.lang.String> topics)
Description copied from interface: ConnectionFactory
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.

Specified by:
refreshMetadata in interface ConnectionFactory
Parameters:
topics - the topics for which to refresh the leaders
See Also:
ConnectionFactory.refreshMetadata(Collection)

getPartitions

public java.util.Collection<Partition> getPartitions(java.lang.String topic)
Description copied from interface: ConnectionFactory
Retrieves the partitions of a given topic

Specified by:
getPartitions in interface ConnectionFactory
Parameters:
topic - the topic to query for
Returns:
a list of partitions
See Also:
ConnectionFactory.getPartitions(String)