Ejemplo n.º 1
0
        public KafkaRemoteEventSubscriber(IKafkaSetting kafkaSetting)
        {
            Check.NotNullOrWhiteSpace(kafkaSetting.Properties["bootstrap.servers"] as string, "bootstrap.servers");

            _kafkaSetting = kafkaSetting;

            _dictionary = new ConcurrentDictionary <string, Consumer <Ignore, string> >();

            Logger = NullLogger.Instance;
        }
        public KafkaRemoteEventPublisher(IKafkaSetting kafkaSetting, IRemoteEventSerializer remoteEventSerializer)
        {
            Check.NotNullOrWhiteSpace(kafkaSetting.Properties["bootstrap.servers"] as string, "bootstrap.servers");

            _remoteEventSerializer = remoteEventSerializer;

            Logger = NullLogger.Instance;

            _producer = new Producer <Null, string>(kafkaSetting.Properties, null, new StringSerializer(Encoding.UTF8));
        }
        public IKafkaConfiguration Configure(IKafkaSetting setting)
        {
            _configuration.IocManager.IocContainer.Register(
                Component.For <IRemoteEventPublisher>()
                .ImplementedBy <KafkaRemoteEventPublisher>()
                .DependsOn(Castle.MicroKernel.Registration.Dependency.OnValue <IKafkaSetting>(setting))
                .Named(Guid.NewGuid().ToString())
                .LifestyleSingleton()
                .IsDefault()
                );

            _configuration.IocManager.IocContainer.Register(
                Component.For <IRemoteEventSubscriber>()
                .ImplementedBy <KafkaRemoteEventSubscriber>()
                .DependsOn(Castle.MicroKernel.Registration.Dependency.OnValue <IKafkaSetting>(setting))
                .Named(Guid.NewGuid().ToString())
                .LifestyleSingleton()
                .IsDefault()
                );

            return(this);
        }