예제 #1
0
        public SystemService(
            ILogger <SystemService> logger,
            IServiceProvider serviceProvider,
            IXNodeConnectionRepository xNodeConnectionRepository,
            SystemIOService systemIOService,
            TenantIOService tenantIOService,
            ProducerIOService producerIOService,
            ConsumerIOService consumerIOService,
            MessageIOService messageIOService2)
        {
            _logger          = logger;
            _serviceProvider = serviceProvider;

            _xNodeConnectionRepository = xNodeConnectionRepository;
            _systemIOService           = systemIOService;
            _tenantIOService           = tenantIOService;
            _producerIOService         = producerIOService;
            _consumerIOService         = consumerIOService;
            _messageIOService2         = messageIOService2;
            nodes       = _serviceProvider.GetService(typeof(List <XNodeConfiguration>)) as List <XNodeConfiguration>;
            dataStorage = _serviceProvider.GetService(typeof(DataStorageConfiguration)) as DataStorageConfiguration;
            agent       = _serviceProvider.GetService(typeof(AgentConfiguration)) as AgentConfiguration;
            partition   = _serviceProvider.GetService(typeof(PartitionConfiguration)) as PartitionConfiguration;
            credentials = _serviceProvider.GetService(typeof(CredentialsConfiguration)) as CredentialsConfiguration;


            DoFileConfiguration();

            UpdateXNodesConfiguration();
            UpdateDataStorageConfiguration();
            UpdateCredentials();

            InitializeServices();
        }
예제 #2
0
        public XNodeEventService(ILogger <SystemService> logger,
                                 string agentId,
                                 XNodeConfiguration nodeConfig,
                                 DataStorageConfiguration dataStorageConfig,
                                 AgentConfiguration agentConfiguration,
                                 IXNodeConnectionRepository xNodeConnectionRepository,
                                 TenantIOService tenantIOService,
                                 ProducerIOService producerIOService,
                                 ConsumerIOService consumerIOService,
                                 MessageIOService messageIOService)
        {
            this.logger = logger;
            this.xNodeConnectionRepository = xNodeConnectionRepository;
            this.tenantIOService           = tenantIOService;
            this.producerIOService         = producerIOService;
            this.consumerIOService         = consumerIOService;
            this.messageIOService          = messageIOService;
            this.agentId    = agentId;
            this.nodeConfig = nodeConfig;

            var provider = new XNodeConnectionProvider(nodeConfig, dataStorageConfig, agentConfiguration, agentId);

            _connection = provider.GetHubConnection();

            _connection.On <AgentConnectedArgs>("StorageConnected", connectedArgs => StorageConnected?.Invoke(connectedArgs));
            _connection.On <AgentDisconnectedArgs>("StorageDisconnected", disconnectedArgs => StorageDisconnected?.Invoke(disconnectedArgs));

            _connection.On <TenantCreatedArgs>("TenantCreated", tenantCreated => TenantCreated?.Invoke(tenantCreated));
            _connection.On <TenantUpdatedArgs>("TenantUpdated", tenantUpdated => TenantUpdated?.Invoke(tenantUpdated));

            _connection.On <ProductCreatedArgs>("ProductCreated", productCreated => ProductCreated?.Invoke(productCreated));
            _connection.On <ProductUpdatedArgs>("ProductUpdated", productUpdated => ProductUpdated?.Invoke(productUpdated));

            _connection.On <ComponentCreatedArgs>("ComponentCreated", componentCreated => ComponentCreated?.Invoke(componentCreated));
            _connection.On <ComponentUpdatedArgs>("ComponentUpdated", componentUpdated => ComponentUpdated?.Invoke(componentUpdated));

            _connection.On <TopicCreatedArgs>("TopicCreated", topicCreated => TopicCreated?.Invoke(topicCreated));
            _connection.On <TopicUpdatedArgs>("TopicUpdated", topicUpdated => TopicUpdated?.Invoke(topicUpdated));

            _connection.On <ProducerConnectedArgs>("ProducerConnected", producerConnected => ProducerConnected?.Invoke(producerConnected));
            _connection.On <ProducerDisconnectedArgs>("ProducerDisconnected", producerDisconnected => ProducerDisconnected?.Invoke(producerDisconnected));

            _connection.On <ConsumerConnectedArgs>("ConsumerConnected", consumerConnected => ConsumerConnected?.Invoke(consumerConnected));
            _connection.On <ConsumerDisconnectedArgs>("ConsumerDisconnected", consumerDisconnected => ConsumerDisconnected?.Invoke(consumerDisconnected));
            _connection.On <ConsumerConnectedArgs>("ConsumerUnacknowledgedMessagesRequested", consumerConnected => ConsumerUnacknowledgedMessagesRequested?.Invoke(consumerConnected));
            _connection.On <MessageAcknowledgedArgs>("MessageAcknowledged", messageAcked => MessageAcknowledged?.Invoke(messageAcked));

            _connection.On <MessageStoredArgs>("MessageStored", msgStored => MessageStored?.Invoke(msgStored));

            InitializeEventHandlers();

            ConnectAsync();

            xNodeConnectionRepository.AddService(nodeConfig.ServiceUrl, agentId, this);
        }
예제 #3
0
        public ConsumerEventHandler(
            ILogger <SystemService> logger,
            XNodeEventService xNodeEventService,
            ConsumerIOService consumerIOService,
            MessageIOService messageIOService)
        {
            _logger            = logger;
            _xNodeEventService = xNodeEventService;
            _consumerIOService = consumerIOService;
            _messageIOService  = messageIOService;
            _unacknowledgedMessageProcesses = new ConcurrentDictionary <string, Task>();

            InitializeEvents();
        }