private Producer <byte[]> CreateProducer(string topic, bool enableBatch, int batchSize = 500) { var pBuilder = new ProducerConfigBuilder <byte[]>(); pBuilder.Topic(topic); if (enableBatch) { pBuilder.EnableBatching(true); pBuilder.BatchBuilder(IBatcherBuilder.KeyBased(_client.ActorSystem)); pBuilder.BatchingMaxMessages(batchSize); pBuilder.BatchingMaxPublishDelay(TimeSpan.FromMilliseconds(5000)); } return(_client.NewProducer(pBuilder)); }
public ProducerConfigBuilder <T> BatchBuilder(IBatcherBuilder builder) { _conf.BatcherBuilder = builder; return(this); }