DefaultKafkaProducerFactory 缓存是如何为事务管理的?

How is the DefaultKafkaProducerFactory cache managed for transactions?

在 spring kafka 文档中 https://docs.spring.io/spring-kafka/docs/2.3.3.RELEASE/reference/html/#transactions

它提到;

Transactions are enabled by providing the DefaultKafkaProducerFactory with a transactionIdPrefix. In that case, instead of managing a single shared Producer, the factory maintains a cache of transactional producers. When the user calls close() on a producer, it is returned to the cache for reuse instead of actually being closed. The transactional.id property of each producer is transactionIdPrefix + n

这取决于交易是否仅是生产者以及默认情况下 trueproducerPerConsumerPartition(对于消费者发起的交易)。

此 属性 是为了支持 EOSMode.ALPHA(或在使用 BETA 但代理早于 2.5 时回退到 ALPHA)。

有关 exactly once 语义的详细信息,请参阅 here

当使用 producerPerConsumerPartition=false 并且对于生产者专用事务时,缓存大小没有限制;缓存为空时创建新的生产者,并在“关闭”时返回缓存。