public RabbitMqBackendCommunication(IConfiguration configuration, IRabbitMqBusFactory busFactory, IOnPremiseConnectorCallbackFactory onPremiseConnectorCallbackFactory, ILogger logger) : base(logger) { _configuration = configuration; _onPremiseConnectorCallbackFactory = onPremiseConnectorCallbackFactory; _logger = logger; _bus = busFactory.CreateBus(); _callbacks = new ConcurrentDictionary <string, IOnPremiseConnectorCallback>(); _onPremiseConsumers = new ConcurrentDictionary <string, IDisposable>(); _onPremises = new ConcurrentDictionary <string, ConnectionInformation>(); _declaredQueues = new ConcurrentDictionary <string, IQueue>(); StartReceivingOnPremiseTargetResponses(OriginId); }
public BackendCommunication(IConfiguration configuration, IMessageDispatcher messageDispatcher, IOnPremiseConnectorCallbackFactory requestCallbackFactory, ILogger logger, IPersistedSettings persistedSettings, ILinkRepository linkRepository) { _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _messageDispatcher = messageDispatcher ?? throw new ArgumentNullException(nameof(messageDispatcher)); _requestCallbackFactory = requestCallbackFactory ?? throw new ArgumentNullException(nameof(requestCallbackFactory)); _logger = logger; _linkRepository = linkRepository ?? throw new ArgumentNullException(nameof(linkRepository)); _requestCompletedCallbacks = new ConcurrentDictionary <string, IOnPremiseConnectorCallback>(StringComparer.OrdinalIgnoreCase); _connectionContexts = new ConcurrentDictionary <string, IOnPremiseConnectionContext>(); _requestSubscriptions = new Dictionary <string, IDisposable>(StringComparer.OrdinalIgnoreCase); _cts = new CancellationTokenSource(); _cancellationToken = _cts.Token; OriginId = persistedSettings?.OriginId ?? throw new ArgumentNullException(nameof(persistedSettings)); _logger?.Verbose("Creating backend communication. origin-id={OriginId}", OriginId); _logger?.Information("Backend communication is using message dispatcher {MessageDispatcherType}", messageDispatcher.GetType().Name); }