Beispiel #1
0
        protected StartupBase()
        {
            var currentDirectory = Directory.GetCurrentDirectory();

            _configuration = new ConfigurationBuilder()
                             .AddJsonFile($"{currentDirectory}\\appSettings.json")
                             .Build();

            _configuration.GetSection("InterServiceCommunication")
            .Bind(_settings = new InterServiceCommunicationSettings());
        }
Beispiel #2
0
        public static void UseInterServiceCommunication(this IServiceCollection services, InterServiceCommunicationSettings settings)
        {
            IMessageClient        messageClient    = null;
            MessageClientSettings producerSettings = null;

            switch (settings.Type)
            {
            case Enumerations.InterServiceCommunicationType.RabbitMQ:
                messageClient = new RabbitMQMessageClient();
                break;

            case Enumerations.InterServiceCommunicationType.Kafka:
            default:
                messageClient    = new KafkaMessageClient();
                producerSettings = new KafkaMessageSettings()
                {
                    BrokerList  = settings.Address,
                    Topics      = settings.Receivers,
                    ServiceName = settings.ServiceName
                };
                break;
            }

            messageClient.InitializeMessageClient(producerSettings);

            services.AddSingleton(messageClient);
        }