Class TopicPartitionOffset
- java.lang.Object
- 
- org.springframework.kafka.support.TopicPartitionOffset
 
- 
 public class TopicPartitionOffset extends java.lang.ObjectA configuration container to represent a topic name, partition number and, optionally, an offset for it. The offset can be:- null- do nothing;
- positive (including 0) - seek to EITHER the absolute offset within the partition or an offset relative to the current position for this consumer, depending onisRelativeToCurrent().
- negative - seek to EITHER the offset relative to the current last offset within
 the partition: consumer.seekToEnd() + initialOffsetOR the relative to the current offset for this consumer (if any), depending onisRelativeToCurrent().
 start()ed. This class is used when manually assigning partitions and for deferred seek operations.- Since:
- 2.3
- Author:
- Artem Bilan, Gary Russell
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classTopicPartitionOffset.SeekPositionEnumeration for "special" seeks.
 - 
Constructor SummaryConstructors Constructor Description TopicPartitionOffset(java.lang.String topic, int partition)Construct an instance with no initial offset management.TopicPartitionOffset(java.lang.String topic, int partition, java.lang.Long offset)Construct an instance with the provided initial offset withisRelativeToCurrent()false.TopicPartitionOffset(java.lang.String topic, int partition, java.lang.Long offset, boolean relativeToCurrent)Construct an instance with the provided initial offset.TopicPartitionOffset(java.lang.String topic, int partition, java.lang.Long offset, TopicPartitionOffset.SeekPosition position)Construct an instance with the providedTopicPartitionOffset.SeekPosition.TopicPartitionOffset(java.lang.String topic, int partition, TopicPartitionOffset.SeekPosition position)Construct an instance with the providedTopicPartitionOffset.SeekPosition.TopicPartitionOffset(org.apache.kafka.common.TopicPartition topicPartition, java.lang.Long offset, TopicPartitionOffset.SeekPosition position)Construct an instance with the providedTopicPartitionOffset.SeekPosition.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.LonggetOffset()intgetPartition()TopicPartitionOffset.SeekPositiongetPosition()java.lang.StringgetTopic()org.apache.kafka.common.TopicPartitiongetTopicPartition()inthashCode()booleanisRelativeToCurrent()voidsetOffset(java.lang.Long offset)Set the offset.voidsetRelativeToCurrent(boolean relativeToCurrent)Set whether the offset is relative to the current position.java.lang.StringtoString()
 
- 
- 
- 
Constructor Detail- 
TopicPartitionOffsetpublic TopicPartitionOffset(java.lang.String topic, int partition)Construct an instance with no initial offset management.- Parameters:
- topic- the topic.
- partition- the partition.
 
 - 
TopicPartitionOffsetpublic TopicPartitionOffset(java.lang.String topic, int partition, java.lang.Long offset)Construct an instance with the provided initial offset withisRelativeToCurrent()false.- Parameters:
- topic- the topic.
- partition- the partition.
- offset- the offset.
- See Also:
- TopicPartitionOffset(String, int, Long, boolean)
 
 - 
TopicPartitionOffsetpublic TopicPartitionOffset(java.lang.String topic, int partition, java.lang.Long offset, boolean relativeToCurrent)Construct an instance with the provided initial offset.- Parameters:
- topic- the topic.
- partition- the partition.
- offset- the initial offset.
- relativeToCurrent- true for the initial offset to be relative to the current consumer position, false for a positive initial offset to be absolute and a negative offset relative to the current end of the partition.
 
 - 
TopicPartitionOffsetpublic TopicPartitionOffset(java.lang.String topic, int partition, TopicPartitionOffset.SeekPosition position)Construct an instance with the providedTopicPartitionOffset.SeekPosition.- Parameters:
- topic- the topic.
- partition- the partition.
- position-- TopicPartitionOffset.SeekPosition.
 
 - 
TopicPartitionOffsetpublic TopicPartitionOffset(java.lang.String topic, int partition, java.lang.Long offset, @Nullable TopicPartitionOffset.SeekPosition position)Construct an instance with the providedTopicPartitionOffset.SeekPosition.- Parameters:
- topic- the topic.
- partition- the partition.
- offset- the offset from the seek position (or timestamp for- TopicPartitionOffset.SeekPosition.TIMESTAMP).
- position-- TopicPartitionOffset.SeekPosition.
- Since:
- 2.3
 
 - 
TopicPartitionOffsetpublic TopicPartitionOffset(org.apache.kafka.common.TopicPartition topicPartition, java.lang.Long offset, @Nullable TopicPartitionOffset.SeekPosition position)Construct an instance with the providedTopicPartitionOffset.SeekPosition.- Parameters:
- topicPartition- the topic/partition.
- offset- the offset from the seek position (or timestamp for- TopicPartitionOffset.SeekPosition.TIMESTAMP).
- position-- TopicPartitionOffset.SeekPosition.
- Since:
- 2.3
 
 
- 
 - 
Method Detail- 
getTopicPartitionpublic org.apache.kafka.common.TopicPartition getTopicPartition() 
 - 
getPartitionpublic int getPartition() 
 - 
getTopicpublic java.lang.String getTopic() 
 - 
getOffsetpublic java.lang.Long getOffset() 
 - 
setOffsetpublic void setOffset(java.lang.Long offset) Set the offset.- Parameters:
- offset- the offset.
- Since:
- 2.5.5
 
 - 
isRelativeToCurrentpublic boolean isRelativeToCurrent() 
 - 
setRelativeToCurrentpublic void setRelativeToCurrent(boolean relativeToCurrent) Set whether the offset is relative to the current position.- Parameters:
- relativeToCurrent- true for relative to current.
- Since:
- 2.5.5
 
 - 
getPositionpublic TopicPartitionOffset.SeekPosition getPosition() 
 - 
equalspublic boolean equals(java.lang.Object o) - Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-