Skip to content

Commit ef2c4ff

Browse files
authored
refactor: added feign timeouts and changed consumer intervals (#146)
* refactor: added feign timeouts and changed consumer intervals * style: style * refactor: increased max poll interval to 2 mins * refactor: increased feign timeout to 10s * chore: updated version to 1.3.9
1 parent 47ddbf0 commit ef2c4ff

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
ext {
9-
set("PROJECT_VERSION", "1.3.8")
9+
set("PROJECT_VERSION", "1.3.9")
1010
}
1111

1212
// doesn't work in build.gradle in buildSrc project

kafka_message_consumer/src/main/java/ru/dankoy/kafkamessageconsumer/config/kafka/KafkaBatchWithOneContainerFactoryForTwoListenersAndRecordFilterConfig.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ public ConsumerFactory<String, CoubMessage> consumerFactoryCoubMessage(
9696
props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, 3);
9797

9898
// polling interval. how many seconds consumer can work with pack of messages
99-
props.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, 20_000);
99+
// time to process last polled records + idle between polls must be less than
100+
// max.poll.interval.ms.
101+
props.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, 120_000);
100102

101103
// before he hits new poll
102104
props.put(ConsumerConfig.RETRY_BACKOFF_MS_CONFIG, 500);
@@ -138,7 +140,7 @@ public KafkaListenerContainerFactory<?> jsonKafkaListenerContainerFactory(
138140

139141
// if you have one consumer but two topics or partitions, then set to two, etc.
140142
factory.setConcurrency(2);
141-
factory.getContainerProperties().setIdleBetweenPolls(30_000); // polling interval
143+
factory.getContainerProperties().setIdleBetweenPolls(10_000); // polling interval
142144
factory
143145
.getContainerProperties()
144146
.setPollTimeout(1_000); // wait in kafka for messages if queue is empty
@@ -147,7 +149,8 @@ public KafkaListenerContainerFactory<?> jsonKafkaListenerContainerFactory(
147149
factory.setCommonErrorHandler(errorHandler());
148150

149151
// idlebeetweenpolls - in pair with maxPollInterval make time between two polls
150-
// somehow these settings make consumer consume messages every 15 seconds
152+
// somehow these settings make (idleBetweenPolls=30_000 and maxPollInterval=20_000) consumer
153+
// consume messages every 15 seconds
151154

152155
factory.getContainerProperties().setListenerTaskExecutor(concurrentTaskExecutor());
153156
return factory;

kafka_message_consumer/src/main/resources/application.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ spring:
3131
listener:
3232
ack-mode: batch
3333

34-
34+
feign:
35+
client:
36+
config:
37+
default:
38+
connectTimeout: 10000
39+
readTimeout: 10000
3540

3641
server:
3742
port: 8085

0 commit comments

Comments
 (0)