コード例 #1
0
        static async Task Main(string[] args)
        {
            var cts = new CancellationTokenSource();

            Console.CancelKeyPress += (_, e) => {
                e.Cancel = true; // prevent the process from terminating.
                cts.Cancel();
            };

            var config = new KafkaConfig();

            var cache = new SubjectNameSchemaCache();

            cache.Init(config.UsersTopic);

            var userConsumer = new UserConsumer
                               (
                config: config,
                cts: cts,
                name: "UserConsumer",
                topicName: config.UsersTopic,
                cache: cache
                               );

            await userConsumer.Consume();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: mickdelaney/kafka-spike
        static async Task Main(string[] args)
        {
            var cts = new CancellationTokenSource();

            Console.CancelKeyPress += (_, e) => {
                e.Cancel = true; // prevent the process from terminating.
                cts.Cancel();
            };

            var config = new KafkaConfig();

            Console.WriteLine($"UserProducer producing on {config.UsersTopic}. Enter user names, Ctrl+C to exit.");

            var cache = new SubjectNameSchemaCache();

            cache.Init(config.UsersTopic);

            var userProducer = new UserProducer
                               (
                config: config,
                cts: cts,
                name: "UserProducer",
                topicName: config.UsersTopic,
                cache: cache
                               );

            await userProducer.Produce();
        }
コード例 #3
0
 public UserConsumer
 (
     KafkaConfig config,
     CancellationTokenSource cts,
     string name,
     string topicName,
     SubjectNameSchemaCache cache
 )
 {
     _config    = config;
     _cts       = cts;
     _name      = name;
     _topicName = topicName;
     _cache     = cache;
 }