Example #1
0
        public NatsConsumer(
            string topic,
            string environment,
            INatsStreamingConsumerFactory consumerFactory,
            ILogger <NatsConsumer> logger = null)
        {
            Topic       = topic;
            Environment = environment;
            _logger     = logger ?? new NullLogger <NatsConsumer>();

            var clientId = $"{CLIENT_ID}-{Environment}-{Topic.Replace(".", "-")}";

            var subscriptionConfiguration = new NatsStreamingSubscriptionConfigurationBuilder()
                                            .WithSubscriptionName(topic)
                                            .Build();

            _natsStreamingConsumer = consumerFactory.Create(subscriptionConfiguration, clientId);
        }
 public NatsConsumerFactoryBuilder SetupCreate(INatsStreamingConsumer consumer)
 {
     _consumerFactoryMock.Setup(c => c.Create(It.IsAny <INatsStreamingSubscriptionConfiguration>(), It.IsAny <string>(), It.IsAny <IDeserializer>()))
     .Returns(consumer);
     return(this);
 }