-
-
Save ckozak/d1db987150cdee2f3812 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lastOffset(consumer: SimpleConsumer, topic: String, partitionId: Int): Future[Long] = { | |
val topicAndPartition = new TopicAndPartition(topic, partitionId) | |
val requestInfo = Map( | |
topicAndPartition -> new PartitionOffsetRequestInfo(OffsetRequest.LatestTime, 1) | |
) | |
val request = new OffsetRequest(requestInfo, correlationId = Random.nextInt()) | |
val response = Future(consumer.getOffsetsBefore(request)) | |
response map { response => | |
response.offsetsGroupedByTopic(topic)(topicAndPartition).offsets.head | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment