Skip to content

Commit fc5d433

Browse files
garyrussellartembilan
authored andcommitted
ConsumerSeekAware default implementations
Add default method implementations to avoid users having to implement methods they are not interested in.
1 parent 80388da commit fc5d433

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

spring-kafka/src/main/java/org/springframework/kafka/listener/ConsumerSeekAware.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,28 @@ public interface ConsumerSeekAware {
3737
* containers listeners should store the callback in a {@code ThreadLocal}.
3838
* @param callback the callback.
3939
*/
40-
void registerSeekCallback(ConsumerSeekCallback callback);
40+
default void registerSeekCallback(ConsumerSeekCallback callback) {
41+
// do nothing
42+
}
4143

4244
/**
4345
* When using group management, called when partition assignments change.
4446
* @param assignments the new assignments and their current offsets.
4547
* @param callback the callback to perform an initial seek after assignment.
4648
*/
47-
void onPartitionsAssigned(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback);
49+
default void onPartitionsAssigned(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback) {
50+
// do nothing
51+
}
4852

4953
/**
5054
* If the container is configured to emit idle container events, this method is called
5155
* when the container idle event is emitted - allowing a seek operation.
5256
* @param assignments the new assignments and their current offsets.
5357
* @param callback the callback to perform a seek.
5458
*/
55-
void onIdleContainer(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback);
59+
default void onIdleContainer(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback) {
60+
// do nothing
61+
}
5662

5763
/**
5864
* A callback that a listener can invoke to seek to a specific offset.

spring-kafka/src/test/java/org/springframework/kafka/annotation/EnableKafkaIntegrationTests.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,18 +1689,6 @@ public void registerSeekCallback(ConsumerSeekCallback callback) {
16891689
this.seekCallBack.set(callback);
16901690
}
16911691

1692-
@Override
1693-
public void onPartitionsAssigned(Map<org.apache.kafka.common.TopicPartition, Long> assignments,
1694-
ConsumerSeekCallback callback) {
1695-
// NOSONAR
1696-
}
1697-
1698-
@Override
1699-
public void onIdleContainer(Map<org.apache.kafka.common.TopicPartition, Long> assignments,
1700-
ConsumerSeekCallback callback) {
1701-
// NOSONAR
1702-
}
1703-
17041692
}
17051693

17061694
interface IfaceListener<T> {

0 commit comments

Comments
 (0)