简体   繁体   中英

Spring Kafka: How does kafkaTemplate executeInTransaction method play with Consumer's read_committed isolation level

I am seeing that the isolation.level=read_committed consumer property ensures that only committed messages will be read by the consumer. I am trying to understand what is meant by a committed message in this context exactly? When can we say a producer's message is committed to a topic?

My Specific scenario

I am using Spring-kafka, kafkaTemplate.executeInTransaction method asynchronously to send messages to kafka.

I see executeInTransaction method internally calls producer.commitTransaction() which in turn throws exception if it cannot complete within max.block.ms

My Confusion is

if producer.commitTransaction() completes within max.block.ms , does that mean the message has been stored in the topic successfully, ready for a consumer with isolation.level=read_committed to consume?

I ask this because I see there is another property delivery.timeout.ms which corresponds to processes that start after send() / max.block.ms is complete.

So.. does this mean even after producer.commitTransaction() returns, we still need to wait maximum of delivery.timeout.ms to be certain that the message has been written to a topic?

No; when the commit is successful, the record is secure in the log.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM