|
29 | 29 |
|
30 | 30 | import org.apache.kafka.clients.consumer.Consumer; |
31 | 31 | import org.apache.kafka.clients.consumer.ConsumerRecord; |
32 | | -import org.apache.kafka.clients.consumer.ConsumerRecords; |
33 | 32 | import org.apache.kafka.clients.consumer.OffsetAndMetadata; |
34 | 33 | import org.apache.kafka.common.TopicPartition; |
35 | 34 | import org.apache.kafka.common.header.Header; |
@@ -58,24 +57,26 @@ public class AggregatingReplyingKafkaTemplate<K, V, R> |
58 | 57 | implements BatchConsumerAwareMessageListener<K, Collection<ConsumerRecord<K, R>>> { |
59 | 58 |
|
60 | 59 | /** |
61 | | - * Pseudo topic name for the "outer" {@link ConsumerRecords} that has the aggregated |
| 60 | + * Pseudo topic name for the "outer" {@link ConsumerRecord} that has the aggregated |
62 | 61 | * results in its value after a normal release by the release strategy. |
63 | 62 | */ |
64 | 63 | public static final String AGGREGATED_RESULTS_TOPIC = "aggregatedResults"; |
65 | 64 |
|
66 | 65 | /** |
67 | | - * Pseudo topic name for the "outer" {@link ConsumerRecords} that has the aggregated |
| 66 | + * Pseudo topic name for the "outer" {@link ConsumerRecord} that has the aggregated |
68 | 67 | * results in its value after a timeout. |
69 | 68 | */ |
70 | 69 | public static final String PARTIAL_RESULTS_AFTER_TIMEOUT_TOPIC = "partialResultsAfterTimeout"; |
71 | 70 |
|
| 71 | + private static final int DEFAULT_COMMIT_TIMEOUT = 30; |
| 72 | + |
72 | 73 | private final Map<CorrelationKey, Set<RecordHolder<K, R>>> pending = new HashMap<>(); |
73 | 74 |
|
74 | 75 | private final Map<TopicPartition, Long> offsets = new HashMap<>(); |
75 | 76 |
|
76 | 77 | private final Predicate<Collection<ConsumerRecord<K, R>>> releaseStrategy; |
77 | 78 |
|
78 | | - private Duration commitTimeout = Duration.ofSeconds(30); |
| 79 | + private Duration commitTimeout = Duration.ofSeconds(DEFAULT_COMMIT_TIMEOUT); |
79 | 80 |
|
80 | 81 | private boolean returnPartialOnTimeout; |
81 | 82 |
|
@@ -111,7 +112,7 @@ public void setCommitTimeout(Duration commitTimeout) { |
111 | 112 | * Set to true to return a partial result when a request times out. |
112 | 113 | * @param returnPartialOnTimeout true to return a partial result. |
113 | 114 | */ |
114 | | - public void setReturnPartialOnTimeout(boolean returnPartialOnTimeout) { |
| 115 | + public synchronized void setReturnPartialOnTimeout(boolean returnPartialOnTimeout) { |
115 | 116 | this.returnPartialOnTimeout = returnPartialOnTimeout; |
116 | 117 | } |
117 | 118 |
|
|
0 commit comments