public async Task ProcessCityCreated(CityCreatedMessage message) { if (message == null) { _logger.LogWarning("ProcessCityCreated: message is null."); return; } _logger.LogInformation( $"ProcessCityCreated: Message for City with Id {message.SolutionOneCityId} consumed!"); var actionsGroupColor = GenerateRandomColor(); await _hubContext.Clients.All.ReceiveCityProcessingMessage( CityClientMessage.CityCreatedMessageConsumed(message.SolutionOneCityId, message.Name, actionsGroupColor)); string registryKey = null; try { await _hubContext.Clients.All.ReceiveCityProcessingMessage( CityClientMessage.CityRegistrationRequested(message.SolutionOneCityId, message.Name, actionsGroupColor)); registryKey = await _cityRegistryService.PostRegisterCity(new CityModel { SolutionOneCityId = message.SolutionOneCityId, Name = message.Name, FoundationDate = message.FoundationDate }); } catch (HttpRequestException e) { _logger.LogError(e, "ProcessCityCreated: Http Exception during REST request to City Registry."); } catch (Exception e) { _logger.LogError(e, "ProcessCityCreated: Unexpected Exception during REST request to City Registry."); } if (string.IsNullOrEmpty(registryKey)) { _logger.LogWarning("ProcessCityCreated: Registry key is null."); return; } await _hubContext.Clients.All.ReceiveCityProcessingMessage( CityClientMessage.CityRegistrationCompleted(message.SolutionOneCityId, message.Name, registryKey, actionsGroupColor)); // TODO: Produce CityRegisteredMessage to RabbitMQ }
public void ProduceCityCreated(CityCreatedMessage message) { Produce(message, Queues.CityCreated); }