1
1
/*
2
- * Copyright 2017 the original author or authors.
2
+ * Copyright 2017-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
23
23
import org .apache .kafka .common .TopicPartition ;
24
24
25
25
/**
26
- * A rebalance listener that provides access to the consumer object.
26
+ * A rebalance listener that provides access to the consumer object. Starting with version
27
+ * 2.1.5, as a convenience, default no-op implementations are provided for all methods,
28
+ * allowing the user to implement just those (s)he is interested in.
27
29
*
28
30
* @author Gary Russell
29
31
* @since 2.0
@@ -37,23 +39,29 @@ public interface ConsumerAwareRebalanceListener extends ConsumerRebalanceListene
37
39
* @param consumer the consumer.
38
40
* @param partitions the partitions.
39
41
*/
40
- void onPartitionsRevokedBeforeCommit (Consumer <?, ?> consumer , Collection <TopicPartition > partitions );
42
+ default void onPartitionsRevokedBeforeCommit (Consumer <?, ?> consumer , Collection <TopicPartition > partitions ) {
43
+ // do nothing
44
+ }
41
45
42
46
/**
43
47
* The same as {@link #onPartitionsRevoked(Collection)} with the additional consumer
44
48
* parameter. It is invoked by the container after any pending offsets are committed.
45
49
* @param consumer the consumer.
46
50
* @param partitions the partitions.
47
51
*/
48
- void onPartitionsRevokedAfterCommit (Consumer <?, ?> consumer , Collection <TopicPartition > partitions );
52
+ default void onPartitionsRevokedAfterCommit (Consumer <?, ?> consumer , Collection <TopicPartition > partitions ) {
53
+ // do nothing
54
+ }
49
55
50
56
/**
51
57
* The same as {@link #onPartitionsAssigned(Collection)} with the additional consumer
52
58
* parameter.
53
59
* @param consumer the consumer.
54
60
* @param partitions the partitions.
55
61
*/
56
- void onPartitionsAssigned (Consumer <?, ?> consumer , Collection <TopicPartition > partitions );
62
+ default void onPartitionsAssigned (Consumer <?, ?> consumer , Collection <TopicPartition > partitions ) {
63
+ // do nothing
64
+ }
57
65
58
66
@ Override
59
67
default void onPartitionsRevoked (Collection <TopicPartition > partitions ) {
0 commit comments