Exemplo n.º 1
0
        private static void Connect()
        {
            _producer = _broker.GetProducer(new KafkaProducerEndpoint("Topic1")
            {
                Configuration = new KafkaProducerConfig
                {
                    BootstrapServers = "PLAINTEXT://localhost:9092"
                }
            });

            _broker.Connect();

            Console.CancelKeyPress += (_, e) => { _broker.Disconnect(); };
        }
Exemplo n.º 2
0
        private static void Connect()
        {
            _consumer = _broker.GetConsumer(new KafkaConsumerEndpoint("Topic1")
            {
                Configuration = new KafkaConsumerConfig
                {
                    BootstrapServers = "PLAINTEXT://localhost:9092",
                    GroupId          = "silverback-consumer",
                    AutoOffsetReset  = Confluent.Kafka.AutoOffsetReset.Earliest
                },
                Serializer = new JsonMessageSerializer <TestMessage>()
            });

            _consumer.Received += OnMessageReceived;

            _broker.Connect();

            Console.CancelKeyPress += (_, e) =>
            {
                _broker.Disconnect();
                _activity.Stop();
            };
        }
Exemplo n.º 3
0
 private static void Disconnect()
 {
     _broker.Disconnect();
 }