Class KafkaMessageProducer<K,​V>

  • All Implemented Interfaces:
    MessageProducer<K,​V>

    public class KafkaMessageProducer<K,​V>
    extends java.lang.Object
    implements MessageProducer<K,​V>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void flush()
      This method is a blank default implementation in order to avoid it being a breaking change.
      java.util.concurrent.Future<org.apache.kafka.clients.producer.RecordMetadata> send​(K key, V value, org.apache.kafka.common.header.Headers headers, org.apache.kafka.clients.producer.Callback callback)
      Asynchronously send a record to a specific topic and invoke the provided callback when the sending has been acknowledged.
      • Methods inherited from class java.lang.Object

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

      • KafkaMessageProducer

        public KafkaMessageProducer​(java.lang.String topic,
                                    org.apache.kafka.clients.producer.Producer<K,​V> producer,
                                    ProducerTopicMessageCounter msgCounter,
                                    java.lang.String producerName)
    • Method Detail

      • send

        public java.util.concurrent.Future<org.apache.kafka.clients.producer.RecordMetadata> send​(K key,
                                                                                                  V value,
                                                                                                  org.apache.kafka.common.header.Headers headers,
                                                                                                  org.apache.kafka.clients.producer.Callback callback)
        Description copied from interface: MessageProducer
        Asynchronously send a record to a specific topic and invoke the provided callback when the sending has been acknowledged. The sending is asynchronous and this method will return immediately once the record has been stored in the buffer of records waiting to be sent.
        Specified by:
        send in interface MessageProducer<K,​V>
        Parameters:
        key - key to send
        value - value to send
        headers - headers to include in the message
        callback - callback to invoke
        Returns:
        The result of sending is a RecordMetadata specifying the partition the record was sent to, the offset it was assigned and the timestamp of the record. Noop implementations may return null instead of a Future.
      • close

        public void close()
      • flush

        public void flush()
        Description copied from interface: MessageProducer
        This method is a blank default implementation in order to avoid it being a breaking change. The implementing class must override this to add behaviour to it. The implementation should call the flush() method of the producer.
        Specified by:
        flush in interface MessageProducer<K,​V>