private void SendPlanetExplorationResult(ExplorationResponse response) { m_rabbitHandler.PublishRpc(new PublishOptions { TargetQueue = m_appSettings.RabbitMqQueues.SolarApiQueue, Headers = new Dictionary <string, object> { { nameof(MessageType), nameof(MessageType.ExplorationFinished) }, }, Message = JsonConvert.SerializeObject(response) }); }
public async Task SendRobotsToPlanetAsync(IFilter <Robot> filter, Guid planetId) { try { var(_, searchedRobots) = await SearchRobotAsync(new Pagination(), new Ordering(), filter); var response = m_rabbitHandler.PublishRpc <RabbitResponse>(new PublishOptions { TargetQueue = m_appSettings.RabbitMqQueues.SolarApiQueue, Message = JsonConvert.SerializeObject(new { PlanetId = planetId, Robots = searchedRobots }), Headers = new Dictionary <string, object> { { nameof(MessageType), nameof(MessageType.SendRobotsToPlanet) } } }); if (response.IsSuccessful) { var(_, bots) = await SearchRobotAsync(new Pagination(), new Ordering(), filter); bots.ForEach(robot => { robot.CurrentStatus = RobotStatus.Occupied; robot.CurrentPlanetId = planetId; }); await m_repository.UpdateAsync(bots); } } catch (ValidationException e) { m_logger.LogWarning(e, "A validation failed"); throw; } catch (Exception e) when(e.GetType() != typeof(ValidationException)) { m_logger.LogCritical(e, "Unexpected Exception while trying to send the robots to the planet"); throw; } }