コード例 #1
0
        public GreetingQueue(IOptions <GreetQueueOptions> options, ISerializer <Guid> guidSerializer, IDeserializer <Guid> guidDeserializer, IMicroserviceIdProvider microserviceIdProvider)
        {
            _guidSerializer         = guidSerializer;
            _guidDeserializer       = guidDeserializer;
            _microserviceIdProvider = microserviceIdProvider;

            _options = options.Value;

            var producerConfig = new ProducerConfig
            {
                BootstrapServers = _options.Servers
            };

            _producer = new ProducerBuilder <Guid, string>(producerConfig)
                        .SetKeySerializer(_guidSerializer)
                        .Build();

            var consumerConfig = new ConsumerConfig
            {
                BootstrapServers = _options.Servers,
                GroupId          = _options.Group,
                AutoOffsetReset  = AutoOffsetReset.Earliest
            };

            _consumer = new ConsumerBuilder <Guid, string>(consumerConfig)
                        .SetKeyDeserializer(_guidDeserializer)
                        .Build();

            _consumer.Subscribe(_options.Topic);
        }
コード例 #2
0
 public GreetingManager(IMicroserviceIdProvider microServiceIdentification, IMessageQueue <Greeting> messageQueue, ILogger <GreetingManager> logger)
 {
     _microServiceIdentification = microServiceIdentification;
     _messageQueue = messageQueue;
     _logger       = logger;
 }