Esempio n. 1
0
 public kafkaConfWrapper()
 {
     kafkaProducer          = new kafkaProducerConf();
     kafkaRPC               = new kafkaRPCConf();
     opcSystemName          = "OPC";
     KafkaSchemaRegistryURL = "localhost:8081";
     KafkaServers           = "localhost:9092";
 }
Esempio n. 2
0
        public opcKafkaProducer(kafkaProducerConf conf, CachedSchemaRegistryClient schemaRegistry)
        {
            _conf = conf;

            // setup the logger
            log = LogManager.GetLogger(this.GetType().Name);

            // instance the List of schemas
            schemas = new opcSchemas();

            // instace producer with Avro serializers
            producer = new ProducerBuilder <string, GenericRecord>(_conf.getProducerConf())
                       //.SetKeySerializer(new AvroSerializer<string>(schemaRegistry))
                       .SetValueSerializer(new AvroSerializer <GenericRecord>(schemaRegistry))
                       .SetErrorHandler((_, e) => log.Error($"Error: {e.Reason}"))
                       .Build();

            log.Info("Producer streaming to broker: " + _conf.BootstrapServers);
            log.Info("Data stream on topic: " + _conf.opcSystemName);
        }