Class SidecarProducer

  • All Implemented Interfaces:
    LightProducer, NativeLightProducer

    public class SidecarProducer
    extends Object
    implements NativeLightProducer
    This is the guaranteed producer to ensure that the message is acknowledged from the Kafka brokers before the service is respond to the consumer call. Although this producer is not the best one for high throughput batch producing, it is the safest one. Once the caller receives the successful response from the service, it can make sure that the message is on the Kafka cluster.
    Author:
    Steve Hu
    • Field Detail

      • producer

        public org.apache.kafka.clients.producer.Producer<byte[],​byte[]> producer
    • Constructor Detail

      • SidecarProducer

        public SidecarProducer()
    • Method Detail

      • open

        public void open()
        Description copied from interface: LightProducer
        This method is used to create an instance of producer in a startup hook for most of the producers. 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:
        open in interface LightProducer
      • getProducer

        public org.apache.kafka.clients.producer.Producer getProducer()
        Description copied from interface: NativeLightProducer
        Return the Kafka Producer instance so that it can be used to produce message to a Kafka topic. Instead of using a queue like QueuedLightProducer to hide the producer from the user, this interface will provide the native producer to work with.
        Specified by:
        getProducer in interface NativeLightProducer
        Returns:
        Kafka producer instance
      • close

        public void close()
        Description copied from interface: LightProducer
        This method is called by a shutdown hook to close the producer if it is not null.
        Specified by:
        close in interface LightProducer