Kafka producer TimeoutException: Expiring 1 record(s)
up vote
9
down vote
favorite
I am using Kafka with Spring-boot:
Kafka Producer class:
@Service
public class MyKafkaProducer
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
private static Logger LOGGER = LoggerFactory.getLogger(NotificationDispatcherSender.class);
// Send Message
public void sendMessage(String topicName, String message) throws Exception
LOGGER.debug("========topic Name===== " + topicName + "=========message=======" + message);
ListenableFuture<SendResult<String, String>> result = kafkaTemplate.send(topicName, message);
result.addCallback(new ListenableFutureCallback<SendResult<String, String>>()
@Override
public void onSuccess(SendResult<String, String> result)
LOGGER.debug("sent message='' with offset=", message, result.getRecordMetadata().offset());
@Override
public void onFailure(Throwable ex)
LOGGER.error(Constants.PRODUCER_MESSAGE_EXCEPTION.getValue() + " : " + ex.getMessage());
);
Kafka-configuration:
spring.kafka.producer.retries=0
spring.kafka.producer.batch-size=100000
spring.kafka.producer.request.timeout.ms=30000
spring.kafka.producer.linger.ms=10
spring.kafka.producer.acks=0
spring.kafka.producer.buffer-memory=33554432
spring.kafka.producer.max.block.ms=5000
spring.kafka.bootstrap-servers=192.168.1.161:9092,192.168.1.162:9093
Let's say I have sent 10 times 1000 messages in topic my-test-topic
.
8 out of 10 times I am successfully getting all messages in my consumer but sometimes I am getting this below error:
2017-10-05 07:24:11, [ERROR] [my-service - LoggingProducerListener - onError:76] Exception thrown when sending a message with key='null' and payload='{"deviceType":"X","deviceKeys":["apiKey":"X-X-o"],"devices...' to topic my-test-topic
and org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for my-test-topic-4 due to 30024 ms has passed since batch creation plus linger time
apache-kafka kafka-consumer-api kafka-producer-api spring-kafka
|
show 1 more comment
up vote
9
down vote
favorite
I am using Kafka with Spring-boot:
Kafka Producer class:
@Service
public class MyKafkaProducer
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
private static Logger LOGGER = LoggerFactory.getLogger(NotificationDispatcherSender.class);
// Send Message
public void sendMessage(String topicName, String message) throws Exception
LOGGER.debug("========topic Name===== " + topicName + "=========message=======" + message);
ListenableFuture<SendResult<String, String>> result = kafkaTemplate.send(topicName, message);
result.addCallback(new ListenableFutureCallback<SendResult<String, String>>()
@Override
public void onSuccess(SendResult<String, String> result)
LOGGER.debug("sent message='' with offset=", message, result.getRecordMetadata().offset());
@Override
public void onFailure(Throwable ex)
LOGGER.error(Constants.PRODUCER_MESSAGE_EXCEPTION.getValue() + " : " + ex.getMessage());
);
Kafka-configuration:
spring.kafka.producer.retries=0
spring.kafka.producer.batch-size=100000
spring.kafka.producer.request.timeout.ms=30000
spring.kafka.producer.linger.ms=10
spring.kafka.producer.acks=0
spring.kafka.producer.buffer-memory=33554432
spring.kafka.producer.max.block.ms=5000
spring.kafka.bootstrap-servers=192.168.1.161:9092,192.168.1.162:9093
Let's say I have sent 10 times 1000 messages in topic my-test-topic
.
8 out of 10 times I am successfully getting all messages in my consumer but sometimes I am getting this below error:
2017-10-05 07:24:11, [ERROR] [my-service - LoggingProducerListener - onError:76] Exception thrown when sending a message with key='null' and payload='{"deviceType":"X","deviceKeys":["apiKey":"X-X-o"],"devices...' to topic my-test-topic
and org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for my-test-topic-4 due to 30024 ms has passed since batch creation plus linger time
apache-kafka kafka-consumer-api kafka-producer-api spring-kafka
Is this error you are describing from the producer or the consumer?
– adarshr
Oct 9 '17 at 15:19
I am getting this error on producer
– Prakash Pandey
Oct 9 '17 at 15:20
So, your batch is too slow for such a "low"request.timeout.ms
. Try to makebatch-size
a bit lower
– Artem Bilan
Oct 9 '17 at 15:31
Isn't 30 second enough?( I am new to Kafka, please bear with me)
– Prakash Pandey
Oct 9 '17 at 15:38
I don't know, but according your error you are really exceeding those 30 secs:due to 30024 ms has passed
– Artem Bilan
Oct 9 '17 at 16:35
|
show 1 more comment
up vote
9
down vote
favorite
up vote
9
down vote
favorite
I am using Kafka with Spring-boot:
Kafka Producer class:
@Service
public class MyKafkaProducer
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
private static Logger LOGGER = LoggerFactory.getLogger(NotificationDispatcherSender.class);
// Send Message
public void sendMessage(String topicName, String message) throws Exception
LOGGER.debug("========topic Name===== " + topicName + "=========message=======" + message);
ListenableFuture<SendResult<String, String>> result = kafkaTemplate.send(topicName, message);
result.addCallback(new ListenableFutureCallback<SendResult<String, String>>()
@Override
public void onSuccess(SendResult<String, String> result)
LOGGER.debug("sent message='' with offset=", message, result.getRecordMetadata().offset());
@Override
public void onFailure(Throwable ex)
LOGGER.error(Constants.PRODUCER_MESSAGE_EXCEPTION.getValue() + " : " + ex.getMessage());
);
Kafka-configuration:
spring.kafka.producer.retries=0
spring.kafka.producer.batch-size=100000
spring.kafka.producer.request.timeout.ms=30000
spring.kafka.producer.linger.ms=10
spring.kafka.producer.acks=0
spring.kafka.producer.buffer-memory=33554432
spring.kafka.producer.max.block.ms=5000
spring.kafka.bootstrap-servers=192.168.1.161:9092,192.168.1.162:9093
Let's say I have sent 10 times 1000 messages in topic my-test-topic
.
8 out of 10 times I am successfully getting all messages in my consumer but sometimes I am getting this below error:
2017-10-05 07:24:11, [ERROR] [my-service - LoggingProducerListener - onError:76] Exception thrown when sending a message with key='null' and payload='{"deviceType":"X","deviceKeys":["apiKey":"X-X-o"],"devices...' to topic my-test-topic
and org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for my-test-topic-4 due to 30024 ms has passed since batch creation plus linger time
apache-kafka kafka-consumer-api kafka-producer-api spring-kafka
I am using Kafka with Spring-boot:
Kafka Producer class:
@Service
public class MyKafkaProducer
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
private static Logger LOGGER = LoggerFactory.getLogger(NotificationDispatcherSender.class);
// Send Message
public void sendMessage(String topicName, String message) throws Exception
LOGGER.debug("========topic Name===== " + topicName + "=========message=======" + message);
ListenableFuture<SendResult<String, String>> result = kafkaTemplate.send(topicName, message);
result.addCallback(new ListenableFutureCallback<SendResult<String, String>>()
@Override
public void onSuccess(SendResult<String, String> result)
LOGGER.debug("sent message='' with offset=", message, result.getRecordMetadata().offset());
@Override
public void onFailure(Throwable ex)
LOGGER.error(Constants.PRODUCER_MESSAGE_EXCEPTION.getValue() + " : " + ex.getMessage());
);
Kafka-configuration:
spring.kafka.producer.retries=0
spring.kafka.producer.batch-size=100000
spring.kafka.producer.request.timeout.ms=30000
spring.kafka.producer.linger.ms=10
spring.kafka.producer.acks=0
spring.kafka.producer.buffer-memory=33554432
spring.kafka.producer.max.block.ms=5000
spring.kafka.bootstrap-servers=192.168.1.161:9092,192.168.1.162:9093
Let's say I have sent 10 times 1000 messages in topic my-test-topic
.
8 out of 10 times I am successfully getting all messages in my consumer but sometimes I am getting this below error:
2017-10-05 07:24:11, [ERROR] [my-service - LoggingProducerListener - onError:76] Exception thrown when sending a message with key='null' and payload='{"deviceType":"X","deviceKeys":["apiKey":"X-X-o"],"devices...' to topic my-test-topic
and org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for my-test-topic-4 due to 30024 ms has passed since batch creation plus linger time
apache-kafka kafka-consumer-api kafka-producer-api spring-kafka
apache-kafka kafka-consumer-api kafka-producer-api spring-kafka
edited Dec 31 '17 at 11:09
michalbrz
1,3991023
1,3991023
asked Oct 9 '17 at 15:15
Prakash Pandey
6581028
6581028
Is this error you are describing from the producer or the consumer?
– adarshr
Oct 9 '17 at 15:19
I am getting this error on producer
– Prakash Pandey
Oct 9 '17 at 15:20
So, your batch is too slow for such a "low"request.timeout.ms
. Try to makebatch-size
a bit lower
– Artem Bilan
Oct 9 '17 at 15:31
Isn't 30 second enough?( I am new to Kafka, please bear with me)
– Prakash Pandey
Oct 9 '17 at 15:38
I don't know, but according your error you are really exceeding those 30 secs:due to 30024 ms has passed
– Artem Bilan
Oct 9 '17 at 16:35
|
show 1 more comment
Is this error you are describing from the producer or the consumer?
– adarshr
Oct 9 '17 at 15:19
I am getting this error on producer
– Prakash Pandey
Oct 9 '17 at 15:20
So, your batch is too slow for such a "low"request.timeout.ms
. Try to makebatch-size
a bit lower
– Artem Bilan
Oct 9 '17 at 15:31
Isn't 30 second enough?( I am new to Kafka, please bear with me)
– Prakash Pandey
Oct 9 '17 at 15:38
I don't know, but according your error you are really exceeding those 30 secs:due to 30024 ms has passed
– Artem Bilan
Oct 9 '17 at 16:35
Is this error you are describing from the producer or the consumer?
– adarshr
Oct 9 '17 at 15:19
Is this error you are describing from the producer or the consumer?
– adarshr
Oct 9 '17 at 15:19
I am getting this error on producer
– Prakash Pandey
Oct 9 '17 at 15:20
I am getting this error on producer
– Prakash Pandey
Oct 9 '17 at 15:20
So, your batch is too slow for such a "low"
request.timeout.ms
. Try to make batch-size
a bit lower– Artem Bilan
Oct 9 '17 at 15:31
So, your batch is too slow for such a "low"
request.timeout.ms
. Try to make batch-size
a bit lower– Artem Bilan
Oct 9 '17 at 15:31
Isn't 30 second enough?( I am new to Kafka, please bear with me)
– Prakash Pandey
Oct 9 '17 at 15:38
Isn't 30 second enough?( I am new to Kafka, please bear with me)
– Prakash Pandey
Oct 9 '17 at 15:38
I don't know, but according your error you are really exceeding those 30 secs:
due to 30024 ms has passed
– Artem Bilan
Oct 9 '17 at 16:35
I don't know, but according your error you are really exceeding those 30 secs:
due to 30024 ms has passed
– Artem Bilan
Oct 9 '17 at 16:35
|
show 1 more comment
2 Answers
2
active
oldest
votes
up vote
3
down vote
There are 3 possibilities:
- Increase
request.timeout.ms
- this is the time that Kafka will wait for whole batch to be ready in buffer. So in your case if there are less than 100 000 messages in buffer, timeout will occur. More info here: https://stackoverflow.com/a/34794261/2707179 - Decrease
batch-size
- related to previous point, it will send batches more often but they will include fewer messages. - Depending on message size, maybe your network cannot catch up with high load? Check if your throughput is not a bottleneck.
3
I have the same issue as OP ever since I enabled SSL on Kafka, and notice that, like me, he has setlinger.ms
. According to the documentation, batches are sent out after this linger time even if the batch is not full, so even with a high batch size it should not time out.
– Jodiug
Jun 4 at 9:08
add a comment |
up vote
1
down vote
Give acks_config="1"
and it will work
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
There are 3 possibilities:
- Increase
request.timeout.ms
- this is the time that Kafka will wait for whole batch to be ready in buffer. So in your case if there are less than 100 000 messages in buffer, timeout will occur. More info here: https://stackoverflow.com/a/34794261/2707179 - Decrease
batch-size
- related to previous point, it will send batches more often but they will include fewer messages. - Depending on message size, maybe your network cannot catch up with high load? Check if your throughput is not a bottleneck.
3
I have the same issue as OP ever since I enabled SSL on Kafka, and notice that, like me, he has setlinger.ms
. According to the documentation, batches are sent out after this linger time even if the batch is not full, so even with a high batch size it should not time out.
– Jodiug
Jun 4 at 9:08
add a comment |
up vote
3
down vote
There are 3 possibilities:
- Increase
request.timeout.ms
- this is the time that Kafka will wait for whole batch to be ready in buffer. So in your case if there are less than 100 000 messages in buffer, timeout will occur. More info here: https://stackoverflow.com/a/34794261/2707179 - Decrease
batch-size
- related to previous point, it will send batches more often but they will include fewer messages. - Depending on message size, maybe your network cannot catch up with high load? Check if your throughput is not a bottleneck.
3
I have the same issue as OP ever since I enabled SSL on Kafka, and notice that, like me, he has setlinger.ms
. According to the documentation, batches are sent out after this linger time even if the batch is not full, so even with a high batch size it should not time out.
– Jodiug
Jun 4 at 9:08
add a comment |
up vote
3
down vote
up vote
3
down vote
There are 3 possibilities:
- Increase
request.timeout.ms
- this is the time that Kafka will wait for whole batch to be ready in buffer. So in your case if there are less than 100 000 messages in buffer, timeout will occur. More info here: https://stackoverflow.com/a/34794261/2707179 - Decrease
batch-size
- related to previous point, it will send batches more often but they will include fewer messages. - Depending on message size, maybe your network cannot catch up with high load? Check if your throughput is not a bottleneck.
There are 3 possibilities:
- Increase
request.timeout.ms
- this is the time that Kafka will wait for whole batch to be ready in buffer. So in your case if there are less than 100 000 messages in buffer, timeout will occur. More info here: https://stackoverflow.com/a/34794261/2707179 - Decrease
batch-size
- related to previous point, it will send batches more often but they will include fewer messages. - Depending on message size, maybe your network cannot catch up with high load? Check if your throughput is not a bottleneck.
answered Dec 30 '17 at 12:49
michalbrz
1,3991023
1,3991023
3
I have the same issue as OP ever since I enabled SSL on Kafka, and notice that, like me, he has setlinger.ms
. According to the documentation, batches are sent out after this linger time even if the batch is not full, so even with a high batch size it should not time out.
– Jodiug
Jun 4 at 9:08
add a comment |
3
I have the same issue as OP ever since I enabled SSL on Kafka, and notice that, like me, he has setlinger.ms
. According to the documentation, batches are sent out after this linger time even if the batch is not full, so even with a high batch size it should not time out.
– Jodiug
Jun 4 at 9:08
3
3
I have the same issue as OP ever since I enabled SSL on Kafka, and notice that, like me, he has set
linger.ms
. According to the documentation, batches are sent out after this linger time even if the batch is not full, so even with a high batch size it should not time out.– Jodiug
Jun 4 at 9:08
I have the same issue as OP ever since I enabled SSL on Kafka, and notice that, like me, he has set
linger.ms
. According to the documentation, batches are sent out after this linger time even if the batch is not full, so even with a high batch size it should not time out.– Jodiug
Jun 4 at 9:08
add a comment |
up vote
1
down vote
Give acks_config="1"
and it will work
add a comment |
up vote
1
down vote
Give acks_config="1"
and it will work
add a comment |
up vote
1
down vote
up vote
1
down vote
Give acks_config="1"
and it will work
Give acks_config="1"
and it will work
edited 20 hours ago
Giorgos Myrianthous
3,50121233
3,50121233
answered Aug 21 at 11:33
user10254546
111
111
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46649748%2fkafka-producer-timeoutexception-expiring-1-records%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Is this error you are describing from the producer or the consumer?
– adarshr
Oct 9 '17 at 15:19
I am getting this error on producer
– Prakash Pandey
Oct 9 '17 at 15:20
So, your batch is too slow for such a "low"
request.timeout.ms
. Try to makebatch-size
a bit lower– Artem Bilan
Oct 9 '17 at 15:31
Isn't 30 second enough?( I am new to Kafka, please bear with me)
– Prakash Pandey
Oct 9 '17 at 15:38
I don't know, but according your error you are really exceeding those 30 secs:
due to 30024 ms has passed
– Artem Bilan
Oct 9 '17 at 16:35