Class KafkaResourceHolder<K,​V>

  • Type Parameters:
    K - the key type.
    V - the value type.
    All Implemented Interfaces:
    org.springframework.transaction.support.ResourceHolder

    public class KafkaResourceHolder<K,​V>
    extends org.springframework.transaction.support.ResourceHolderSupport
    Kafka resource holder, wrapping a Kafka producer. KafkaTransactionManager binds instances of this class to the thread, for a given Kafka producer factory.
    Author:
    Gary Russell
    • Constructor Summary

      Constructors 
      Constructor Description
      KafkaResourceHolder​(org.apache.kafka.clients.producer.Producer<K,​V> producer, java.time.Duration closeTimeout)
      Construct an instance for the producer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void commit()  
      org.apache.kafka.clients.producer.Producer<K,​V> getProducer()  
      void rollback()  
      • Methods inherited from class org.springframework.transaction.support.ResourceHolderSupport

        clear, getDeadline, getTimeToLiveInMillis, getTimeToLiveInSeconds, hasTimeout, isOpen, isRollbackOnly, isSynchronizedWithTransaction, isVoid, released, requested, reset, resetRollbackOnly, setRollbackOnly, setSynchronizedWithTransaction, setTimeoutInMillis, setTimeoutInSeconds, unbound
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • KafkaResourceHolder

        public KafkaResourceHolder​(org.apache.kafka.clients.producer.Producer<K,​V> producer,
                                   java.time.Duration closeTimeout)
        Construct an instance for the producer.
        Parameters:
        producer - the producer.
        closeTimeout - the close timeout.
    • Method Detail

      • getProducer

        public org.apache.kafka.clients.producer.Producer<K,​V> getProducer()
      • commit

        public void commit()
      • close

        public void close()
      • rollback

        public void rollback()