-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
94 additions
and
52 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
...flictvisualizer-api/src/main/java/us/dot/its/jpo/ode/api/kafka/BaseSeekToEndListener.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package us.dot.its.jpo.ode.api.kafka; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
import org.apache.kafka.common.TopicPartition; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.kafka.listener.AbstractConsumerSeekAware; | ||
import us.dot.its.jpo.ode.api.controllers.StompController; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Base class for Kafka listeners that seek to the last offset before consuming when starting up. | ||
* See <a href="https://docs.spring.io/spring-kafka/reference/kafka/seek.html"> | ||
* Spring Kafka: Seeking to a specific offset</a> | ||
*/ | ||
@Slf4j | ||
public class BaseSeekToEndListener extends AbstractConsumerSeekAware { | ||
|
||
protected final StompController stompController; | ||
|
||
public BaseSeekToEndListener(StompController stompController) { | ||
this.stompController = stompController; | ||
} | ||
|
||
@Override | ||
public void onPartitionsAssigned(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback) { | ||
log.info("Seek to end for TopicPartitions {}", assignments.keySet()); | ||
callback.seekToEnd(assignments.keySet()); | ||
super.onPartitionsAssigned(assignments, callback); | ||
} | ||
|
||
} |
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
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
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
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
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