예제 #1
0
 public static MessagePublisher <TMessage> CreatePublisher <TMessage>(
     KafkaConfiguration kafkaConfiguration,
     KafkaProducerConfiguration producerConfiguration,
     string topic,
     IMessageSerializer messageSerializer,
     IScheduler scheduler,
     Func <TMessage, Dictionary <string, string> > propertyProvider)
     where TMessage : class
 {
     return(new MessagePublisher <TMessage>(
                kafkaConfiguration,
                producerConfiguration,
                topic,
                messageSerializer,
                propertyProvider));
 }
예제 #2
0
 public static MessageSource <TMessage> Create <TMessage, TServiceMessage>(
     KafkaConfiguration kafkaConfiguration,
     KafkaSourceConfiguration sourceConfiguration,
     string topic,
     IMessageDeserializerFactory deserializerFactory,
     Func <Dictionary <string, string>, bool> propertyFilter,
     Func <Assembly, bool> assemblyFilter = null,
     Func <Type, bool> typeFilter         = null)
     where TMessage : class
     where TServiceMessage : class
 {
     return(new MessageSource <TMessage>(
                kafkaConfiguration,
                sourceConfiguration,
                topic,
                deserializerFactory.Create <TMessage, TServiceMessage>(assemblyFilter, typeFilter),
                propertyFilter));
 }
        public KafkaServiceEndpointProvider(string serviceName,
                                            KafkaConfiguration kafkaConfiguration, KafkaSourceConfiguration sourceConfiguration,
                                            KafkaProducerConfiguration producerConfiguration,
                                            IMessageSerializer serializer, IMessageDeserializerFactory deserializerFactory,
                                            Func <Dictionary <string, string>, bool> propertyFilter,
                                            Func <TMessage, Dictionary <string, string> > propertyProvider,
                                            Func <Assembly, bool> assemblyFilter = null, Func <Type, bool> typeFilter = null)
            : base(serviceName)
        {
            _kafkaConfiguration    = kafkaConfiguration;
            _sourceConfiguration   = sourceConfiguration ?? new KafkaSourceConfiguration();
            _producerConfiguration = producerConfiguration ?? new KafkaProducerConfiguration();
            _serializer            = serializer;
            _deserializerFactory   = deserializerFactory;
            _assemblyFilter        = assemblyFilter;
            _typeFilter            = typeFilter;
            _propertyFiter         = propertyFilter;
            _propertyProvider      = propertyProvider;

            if (string.IsNullOrEmpty(_kafkaConfiguration?.SeedAddresses))
            {
                throw new InvalidOperationException(string.Format("For service endpoint '{0}', please specify a kafkaUri to connect to. To do this you can use ConnectToKafka() per endpoint", serviceName));
            }
        }
 private IMessagePublisher <T> Create <T>(KafkaConfiguration kafkaConfiguration, KafkaProducerConfiguration producerConfiguration, string topic) where T : class, TMessage
 {
     return(PublisherFactory.CreatePublisher <T>(kafkaConfiguration, producerConfiguration, topic, _serializer, null, _propertyProvider));
 }
 private IMessageSource <T> CreateSource <T>(KafkaConfiguration kafkaConfiguration, KafkaSourceConfiguration sourceConfiguration, string topic) where T : class, TMessage
 {
     return(SourceFactory.Create <T, TServiceMessage>(kafkaConfiguration, sourceConfiguration,
                                                      topic, _deserializerFactory, _propertyFiter, _assemblyFilter, _typeFilter));
 }