private async void MessageReceived(object model, BasicDeliverEventArgs ea, IModel channel) { var inboundMessage = ea.Body; var inboundProperties = ea.BasicProperties; var responseProperties = channel.CreateBasicProperties(); responseProperties.CorrelationId = inboundProperties.CorrelationId; responseProperties.ReplyTo = inboundProperties.ReplyTo; var message = Encoding.UTF8.GetString(inboundMessage.ToArray()); GetSpaceRequest spaceRequest = JsonConvert.DeserializeObject <GetSpaceRequest>(message); logger.LogInformation("Space with guid '{spaceGuid}' is received: ", spaceRequest.SpaceGuid); var spaceResponse = await spacesService.GetAsync(spaceRequest.SpaceGuid); byte[] responseBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject( autoMapper.Map <Response <GetSpaceResponse> >(spaceResponse))); string routingKey = ResponseBindingKeys[0]; channel.BasicPublish(exchange: ResponseExchange, routingKey: routingKey, basicProperties: responseProperties, body: responseBytes); channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false); logger.LogInformation("Response is sent via '{routingKey}' BindingKey", routingKey); }
public async Task <ActionResult <SpaceResponse> > GetSpace( [FromRoute] Guid officeGuid, [FromRoute] Guid spaceGuid) { var response = await spaceService.GetAsync(spaceGuid); return(response.Status == ResponseResult.Success ? Ok(response.Result) : StatusCode((int)response.Error.StatusCode, response.Error.Message)); }