public static async Task<ConfluentResponse<ConsumerInstance>> CreateConsumerInstance(IConfluentClient client, string instanceId, string consumerGroupName) { var request = new CreateConsumerRequest { AutoCommitEnabled = true, InstanceId = instanceId, MessageFormat = MessageFormat.Avro }; return await client.CreateConsumerAsync(consumerGroupName, request); }
private async static void Consume() { IConfluentClient client = new ConfluentClient(new MyConfluentClientSettings()); var request = new CreateConsumerRequest { // Confluent API will create a new InstanceId if not supplied InstanceId = "TestConsumerInstance", MessageFormat = MessageFormat.Avro }; ConfluentResponse<ConsumerInstance> response = await client.CreateConsumerAsync("TestConsumerGroup", request); ConsumerInstance consumerInstance = response.Payload; ConfluentResponse<List<AvroMessage<string, Person>>> response2 = await client.ConsumeAsAvroAsync<string, Person>(consumerInstance, "TestTopic"); foreach (AvroMessage<string, Person> message in response2.Payload) { Person person = message.Value; Console.WriteLine("Name: {0}, Age: {1}", person.Name, person.Age); } await client.CommitOffsetAsync(consumerInstance); }