public Task Publish(FlatDataPointDto flatDataPointDto) { var factory = new ConnectionFactory() { HostName = rabbitConfiguration.HostName }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { var exchange = "weather"; var routingKey = $"{flatDataPointDto.LocationName}.{flatDataPointDto.SensorId}"; var message = JsonConvert.SerializeObject(flatDataPointDto); var body = Encoding.UTF8.GetBytes(message); channel.ExchangeDeclare(exchange: exchange, type: "topic"); channel.BasicPublish(exchange: exchange, routingKey: routingKey, basicProperties: null, body: body); } return(Task.CompletedTask); }
public async Task NewDataPointReceivedAsync(FlatDataPointDto dataPointDto) { await hubContext.Clients.All.SendAsync("ReceiveDataPoint", dataPointDto); }