Class KafkaMessageProducer<K,V>
- java.lang.Object
-
- org.sdase.commons.server.kafka.producer.KafkaMessageProducer<K,V>
-
- All Implemented Interfaces:
MessageProducer<K,V>
public class KafkaMessageProducer<K,V> extends java.lang.Object implements MessageProducer<K,V>
-
-
Constructor Summary
Constructors Constructor Description KafkaMessageProducer(java.lang.String topic, org.apache.kafka.clients.producer.Producer<K,V> producer, ProducerTopicMessageCounter msgCounter, java.lang.String producerName)
-
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
-
Methods inherited from interface org.sdase.commons.server.kafka.producer.MessageProducer
send, send, send
-
-
-
-
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 interfaceMessageProducer<K,V>
- Parameters:
key
- key to sendvalue
- value to sendheaders
- headers to include in the messagecallback
- 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 returnnull
instead of aFuture
.
-
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 interfaceMessageProducer<K,V>
-
-