예제 #1
0
        /// <summary>
        /// This assumes that a topic has only one type.  Jay Kreps recommends separating different event types
        /// into different topics at http://www.confluent.io/blog/stream-data-platform-2/.  Besides, heterogeneous-event
        /// topics aren't directly supported by the driver.
        /// </summary>
        /// <returns></returns>
        private static async Task <ConfluentResponse <List <AvroMessage <TK, TV> > > > ConsumeOnceAsync(
            IConfluentClient confluentClient,
            ConsumerInstance consumerInstance,
            string topic)

        {
            return(await confluentClient.ConsumeAsAvroAsync <TK, TV>(consumerInstance, topic));
        }
예제 #2
0
        private void buttonConsumeAvro_Click(object sender, EventArgs e)
        {
            var maxBytes = GetMaxBytesOrNull();

            if (maxBytes.HasValue)
            {
                Run(() => _confluentClient.ConsumeAsAvroAsync <string, Person>(new ConsumerInstance
                {
                    BaseUri    = string.Format("{0}/consumers/{1}/instances/{2}", _baseUrl, textBoxConsumerGroup.Text, textBoxConsumerId.Text),
                    InstanceId = textBoxConsumerId.Text
                }, textBoxTopic.Text, maxBytes.Value).Result);
            }
            else
            {
                Run(() => _confluentClient.ConsumeAsAvroAsync <string, Person>(new ConsumerInstance
                {
                    BaseUri    = string.Format("{0}/consumers/{1}/instances/{2}", _baseUrl, textBoxConsumerGroup.Text, textBoxConsumerId.Text),
                    InstanceId = textBoxConsumerId.Text
                }, textBoxTopic.Text).Result);
            }
        }