KafkaNet.Producer.SendMessageAsync C# (CSharp) Method

SendMessageAsync() public method

public SendMessageAsync ( Message messages, string topic, int partition, Int16 acks = 1 ) : Task
messages KafkaNet.Protocol.Message
topic string
partition int
acks System.Int16
return Task
        public async Task<ProduceResponse> SendMessageAsync(Message messages, string topic, int partition, Int16 acks = 1)
        {
            var result = await SendMessageAsync(topic, new Message[] { messages }, partition: partition, acks: acks).ConfigureAwait(false);
            return result.FirstOrDefault();
        }

Same methods

Producer::SendMessageAsync ( string topic ) : Task
Producer::SendMessageAsync ( string topic, IEnumerable messages, Int16 acks = 1, System.TimeSpan timeout = null, MessageCodec codec = MessageCodec.CodecNone, int partition = null ) : Task
Producer::SendMessageAsync ( string topic, int partition ) : Task

Usage Example

 public async Task ProducerAckLevel()
 {
     using (var router = new BrokerRouter(new KafkaOptions(IntegrationConfig.IntegrationUri) { Log = IntegrationConfig.NoDebugLog }))
     using (var producer = new Producer(router))
     {
         var responseAckLevel0 = await producer.SendMessageAsync(new Message("Ack Level 0"), IntegrationConfig.IntegrationTopic, acks: 0, partition: 0);
         Assert.AreEqual(responseAckLevel0.Offset, -1);
         var responseAckLevel1 = await producer.SendMessageAsync(new Message("Ack Level 1"), IntegrationConfig.IntegrationTopic, acks: 1, partition: 0);
         Assert.That(responseAckLevel1.Offset, Is.GreaterThan(-1));
     }
 }
All Usage Examples Of KafkaNet.Producer::SendMessageAsync