public class KafkaPartitionAllocator
extends java.lang.Object
implements org.springframework.beans.factory.FactoryBean<org.springframework.integration.kafka.core.Partition[]>
FactoryBean
it will return the partitions that the current module instance should listen to.
The partitions for the given topic would be extracted from Kafka unless an explicit partition list
is provided.
Partitions are allocated evenly based on the number of module instances.
Zero-count Kafka source modules are not supported.Constructor and Description |
---|
KafkaPartitionAllocator(org.springframework.integration.kafka.core.ConnectionFactory connectionFactory,
java.lang.String moduleName,
java.lang.String streamName,
java.lang.String topics,
java.lang.String partitionList,
int sequence,
int count) |
Modifier and Type | Method and Description |
---|---|
org.springframework.integration.kafka.core.Partition[] |
getObject() |
java.lang.Class<?> |
getObjectType() |
boolean |
isSingleton() |
static java.lang.Iterable<java.lang.Integer> |
parseNumberList(java.lang.String numberList)
Expects a String containing a list of numbers or ranges, e.g.
|
public KafkaPartitionAllocator(org.springframework.integration.kafka.core.ConnectionFactory connectionFactory, java.lang.String moduleName, java.lang.String streamName, java.lang.String topics, java.lang.String partitionList, int sequence, int count)
public org.springframework.integration.kafka.core.Partition[] getObject() throws java.lang.Exception
getObject
in interface org.springframework.beans.factory.FactoryBean<org.springframework.integration.kafka.core.Partition[]>
java.lang.Exception
public static java.lang.Iterable<java.lang.Integer> parseNumberList(java.lang.String numberList) throws java.lang.IllegalArgumentException
"1-10"
, "1,3,5"
,
"1,5,10-20,26,100-110,145"
. One-sized ranges or ranges where the start is after the end
are not permitted.
Returns an array of Integers containing the actual numbers.numberList
- a string containing numbers, or rangesjava.lang.IllegalArgumentException
- if the format of the list is incorrectpublic java.lang.Class<?> getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean<org.springframework.integration.kafka.core.Partition[]>
public boolean isSingleton()
isSingleton
in interface org.springframework.beans.factory.FactoryBean<org.springframework.integration.kafka.core.Partition[]>