Exemplo n.º 1
0
 public BusinessConsumer(IEventBusConnection connection, IMapper mapper, IAudioServerRepository audioRepository,
                         IVideoServerRepository videoRepository, IPhotoServerRepository photoRepository, IOptions <EventBusConstants> constants)
 {
     _connection      = connection;
     _mapper          = mapper;
     _audioRepository = audioRepository;
     _videoRepository = videoRepository;
     _photoRepository = photoRepository;
     _constants       = constants.Value;
 }
Exemplo n.º 2
0
        private void AddEventBusServices(IServiceCollection services)
        {
            services.AddSingleton <IEventBusConnection>(sp =>
            {
                string hostName    = Environment.GetEnvironmentVariable("RabbitHostName");
                string userName    = Environment.GetEnvironmentVariable("RabbitUserName");
                string password    = Environment.GetEnvironmentVariable("RabbitPassword");
                string virtualHost = Environment.GetEnvironmentVariable("RabbitVirtualHost");

                int port = int.Parse(Environment.GetEnvironmentVariable("RabbitPort"));

                return(new ConnectionRabbitMQ(hostName, port, userName, password, virtualHost));
            });

            services.AddSingleton <IEventBusSubscriptionsManager, EventBusSubscriptionsManager>();

            services.AddSingleton <IEventBus, EventBusRabbitMQ>(sp =>
            {
                IEventBusConnection rabbitMQConnection = sp.GetRequiredService <IEventBusConnection>();
                IEventBusSubscriptionsManager eventBusSubscriptionManager = sp.GetRequiredService <IEventBusSubscriptionsManager>();
                ILifetimeScope lifetimeScope = sp.GetRequiredService <ILifetimeScope>();

                string exchangeName       = Environment.GetEnvironmentVariable("RabbitExchangeName");
                ExchangeType exchangeType = (ExchangeType)int.Parse(Environment.GetEnvironmentVariable("RabbitExchangeType"));
                bool exchangeIsDurable    = bool.Parse(Environment.GetEnvironmentVariable("RabbitExchangeIsDurable"));
                bool exchangeIsAutoDelete = bool.Parse(Environment.GetEnvironmentVariable("RabbitExchangeIsAutoDelete"));

                EventBusExchange exchange = new EventBusExchange(exchangeName, exchangeType, exchangeIsDurable, exchangeIsAutoDelete, null);

                string queueName       = Environment.GetEnvironmentVariable("RabbitQueueName");
                bool queueIsDurable    = bool.Parse(Environment.GetEnvironmentVariable("RabbitQueueIsDurable"));
                bool queueIsExclusive  = bool.Parse(Environment.GetEnvironmentVariable("RabbitQueueIsExclusive"));
                bool queueIsAutoDelete = bool.Parse(Environment.GetEnvironmentVariable("RabbitQueueIsAutoDelete"));

                EventBusQueue queue = new EventBusQueue(queueName, queueIsDurable, queueIsExclusive, queueIsAutoDelete, null);

                return(new EventBusRabbitMQ(rabbitMQConnection, eventBusSubscriptionManager, lifetimeScope, exchange, queue));
            });

            services.AddTransient <SendLogMessageEventHandler>();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes instance of ServiceBus from the connection string
 /// </summary>
 /// <param name="serviceBusPersisterConnection">AzureServiceBus connection string</param>
 #region Constructor
 public EventBus(IEventBusConnection serviceBus)
 {
     this.serviceBus = serviceBus;
 }
Exemplo n.º 4
0
 public RabbitMqEventBus(IEventBusConnection connection)
 {
     _channel = connection.Connection.CreateModel();
 }
Exemplo n.º 5
0
 public EventConsumer(IEventBusConnection connection)
 {
     _connection = connection;
 }
Exemplo n.º 6
0
 public EventProducer(IEventBusConnection connection)
 {
     _connection = connection ?? throw new ArgumentNullException(nameof(connection));
 }
Exemplo n.º 7
0
 public BusinessProducer(IEventBusConnection connection)
 {
     _connection = connection;
 }