Spring Integration Kafka Support

org.springframework.integration.kafka.listener
Class MetadataStoreOffsetManager

java.lang.Object
  extended by org.springframework.integration.kafka.listener.MetadataStoreOffsetManager
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, OffsetManager

public class MetadataStoreOffsetManager
extends java.lang.Object
implements OffsetManager

An OffsetManager that persists offsets into a MetadataStore.

Author:
Marius Bogoevici

Constructor Summary
MetadataStoreOffsetManager(ConnectionFactory connectionFactory)
           
MetadataStoreOffsetManager(ConnectionFactory connectionFactory, java.util.Map<Partition,java.lang.Long> initialOffsets)
           
 
Method Summary
 void close()
           
 void flush()
           
 java.lang.String getConsumerId()
           
 org.springframework.integration.metadata.MetadataStore getMetadataStore()
           
 long getOffset(Partition partition)
          Retrieves the offset for a given Partition
 long getReferenceTimestamp()
           
 void resetOffsets(java.util.Collection<Partition> partitionsToReset)
          Resets offsets for the given Partitions.
 void setConsumerId(java.lang.String consumerId)
          The identifier of a consumer of Kafka messages.
 void setMetadataStore(org.springframework.integration.metadata.MetadataStore metadataStore)
          The backing MetadataStore for storing offsets.
 void setReferenceTimestamp(long referenceTimestamp)
          A timestamp to be used for resetting initial offsets, if they are not available in the MetadataStore
 void updateOffset(Partition partition, long offset)
          Updates the offset for a given Partition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetadataStoreOffsetManager

public MetadataStoreOffsetManager(ConnectionFactory connectionFactory)

MetadataStoreOffsetManager

public MetadataStoreOffsetManager(ConnectionFactory connectionFactory,
                                  java.util.Map<Partition,java.lang.Long> initialOffsets)
Method Detail

getConsumerId

public java.lang.String getConsumerId()

setConsumerId

public void setConsumerId(java.lang.String consumerId)
The identifier of a consumer of Kafka messages. Allows to store separate sets of offsets in the MetadataStore.

Parameters:
consumerId - the consumer ID

getMetadataStore

public org.springframework.integration.metadata.MetadataStore getMetadataStore()

setMetadataStore

public void setMetadataStore(org.springframework.integration.metadata.MetadataStore metadataStore)
The backing MetadataStore for storing offsets.

Parameters:
metadataStore - a fully configured MetadataStore instance

getReferenceTimestamp

public long getReferenceTimestamp()

setReferenceTimestamp

public void setReferenceTimestamp(long referenceTimestamp)
A timestamp to be used for resetting initial offsets, if they are not available in the MetadataStore

Parameters:
referenceTimestamp - the reset timestamp for initial offsets

updateOffset

public void updateOffset(Partition partition,
                         long offset)
Description copied from interface: OffsetManager
Updates the offset for a given Partition

Specified by:
updateOffset in interface OffsetManager
Parameters:
partition - the partition whose offset is to be updated
offset - the new offset value
See Also:
OffsetManager.updateOffset(Partition, long)

getOffset

public long getOffset(Partition partition)
Description copied from interface: OffsetManager
Retrieves the offset for a given Partition

Specified by:
getOffset in interface OffsetManager
Parameters:
partition - the partition to be
Returns:
the offset value
See Also:
OffsetManager.getOffset(Partition)

resetOffsets

public void resetOffsets(java.util.Collection<Partition> partitionsToReset)
Description copied from interface: OffsetManager
Resets offsets for the given Partitions. To be invoked when the values stored are invalid, so a client cannot resume from that position. Implementations must decide on the best strategy to follow.

Specified by:
resetOffsets in interface OffsetManager
Parameters:
partitionsToReset - to reset

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Throws:
java.io.IOException

Spring Integration Kafka Support