/// <summary> /// Sends a request to Kafka. /// </summary> /// <param name="request">The request to send to Kafka.</param> public void Send(MultiProducerRequest request) { if (request.IsValid()) { using (KafkaConnection connection = new KafkaConnection(Server, Port)) { connection.Write(request); } } }
public void IsValidTrue() { List<ProducerRequest> requests = new List<ProducerRequest> { new ProducerRequest("topic a", 0, new List<Message> { new Message(new byte[10]) }), new ProducerRequest("topic a", 0, new List<Message> { new Message(new byte[10]) }), new ProducerRequest("topic b", 0, new List<Message> { new Message(new byte[10]) }), new ProducerRequest("topic c", 0, new List<Message> { new Message(new byte[10]) }) }; MultiProducerRequest multiRequest = new MultiProducerRequest(requests); Assert.IsTrue(multiRequest.IsValid()); }
public void IsValidNullRequests() { MultiProducerRequest multiRequest = new MultiProducerRequest(null); Assert.IsFalse(multiRequest.IsValid()); }
public void IsValidNoRequests() { MultiProducerRequest multiRequest = new MultiProducerRequest(new List<ProducerRequest>()); Assert.IsFalse(multiRequest.IsValid()); }