public BackgroundMqttClientHostedService(
            IMosquittoClientService client,
            ILogger <BackgroundMqttClientHostedService> logger,
            IMosquittoBrokerService service,
            IMosquittoBrokerPidAccessor accessor,
            IMosquittoBrokerPluginPidService pluginService,
            IHostEnvironment env,
            IConfiguration config)
        {
            _client        = client;
            _logger        = logger;
            _service       = service;
            _accessor      = accessor;
            _pluginService = pluginService;
            _env           = env;

            // Mosquitto handles around 50 more messages/s, 10 ms default is mostly safe enough
            var interval = config.GetSection("SMEIoT")?.GetValue <int>("MosquittoBackgroundClientRunloopInterval");

            if (interval.HasValue && interval.Value > 0)
            {
                _delay = interval.Value;
            }
            else
            {
                throw new InvalidOperationException("SMEIoT__MosquittoBackgroundClientRunloopInterval must be set to a positive milliseconds.");
            }
        }
Ejemplo n.º 2
0
 public BrokerController(
     ILogger <BrokerController> logger,
     IMosquittoBrokerService service,
     IMqttClientConfigService configService,
     IServerHostAccessor hostAccessor)
 {
     _logger        = logger;
     _service       = service;
     _configService = configService;
     _hostAccessor  = hostAccessor;
 }
Ejemplo n.º 3
0
 public MqttMessageIngestionService(
     IDeviceService deviceService,
     IMqttIdentifierService mqttIdentifierService,
     IMosquittoBrokerService brokerService,
     ISensorValueService valueService,
     ILogger <MqttMessageIngestionService> logger
     )
 {
     _deviceService         = deviceService;
     _mqttIdentifierService = mqttIdentifierService;
     _brokerService         = brokerService;
     _valueService          = valueService;
     _logger = logger;
 }
Ejemplo n.º 4
0
        public MqttMessageIngestionServiceTest()
        {
            _dbContext = ApplicationDbContextHelper.BuildTestDbContext();
            _initial   = SystemClock.Instance.GetCurrentInstant();
            _clock     = new FakeClock(_initial);

            var mock = new Mock <IMosquittoBrokerPidAccessor>();

            mock.SetupGet(a => a.BrokerPid).Returns(10000);
            var mockPlugin = new Mock <IMosquittoBrokerPluginPidService>();

            mockPlugin.SetupGet(a => a.BrokerPidFromAuthPlugin).Returns(10000);

            _brokerService = new MosquittoBrokerService(_clock, new NullLogger <MosquittoBrokerService>(), mock.Object, mockPlugin.Object);

            _mqttIdentifierService = new MqttIdentifierService(_clock);
            _deviceService         = new DeviceService(_dbContext, _mqttIdentifierService);
            _valueService          = new SensorValueService(_dbContext);

            _service = new MqttMessageIngestionService(_deviceService, _mqttIdentifierService, _brokerService, _valueService, new NullLogger <MqttMessageIngestionService>());
        }