Package com.networknt.kafka.producer
Interface QueuedLightProducer
-
- All Superinterfaces:
LightProducer
- All Known Implementing Classes:
TransactionalProducer
public interface QueuedLightProducer extends LightProducer
Queued producer that can cache multiple messages in a queue and send them in a batch for maximum throughput. It improves the performance; however, if the server is crashed before the batch is sent out, the consumer doesn't know if the message is sent to the Kafka or not. A poll/push method on the consumer should be established to accept notification if message is pushed to Kafka cluster.- Author:
- Steve Hu
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BlockingQueuegetTxQueue()Get the blocking queue that is used to cache messages so that they can be sent in a batch.voidopen()Queued producer will start a background thread to process the queued message in batch and this method can be used to start the thread in a startup hook.voidpropagateHeaders(org.apache.kafka.clients.producer.ProducerRecord record, io.undertow.server.HttpServerExchange exchange)For each producer, it is responsible for populate the header of the ProducerRecord.-
Methods inherited from interface com.networknt.kafka.producer.LightProducer
close
-
-
-
-
Method Detail
-
open
void open()
Queued producer will start a background thread to process the queued message in batch and this method can be used to start the thread in a startup hook.- Specified by:
openin interfaceLightProducer
-
getTxQueue
BlockingQueue getTxQueue()
Get the blocking queue that is used to cache messages so that they can be sent in a batch.- Returns:
- the queue that contains the cached messages
-
propagateHeaders
void propagateHeaders(org.apache.kafka.clients.producer.ProducerRecord record, io.undertow.server.HttpServerExchange exchange)For each producer, it is responsible for populate the header of the ProducerRecord.- Parameters:
record- the ProducerRecordexchange- the Undertow exchange that carries HTTP headers
-
-