public ResponseId ExecuteAsync(Request request) { try { SetRequestCode(request); Message message = new Message { RequestBody = request.Body, RequestCodeId = request.Code, ExternalSystemId = _externalSystem.Id, RequestUser = request.UserName, IsSyncRequest = false }; _dbContext.Messages.Add(message); _dbContext.SaveChanges(); using (RabbitClient client = new RabbitClient()) { client.PullMessage(message.RequestCodeId, message.Id); } ResponseId response = new ResponseId(); response.Id = message.Id; return(response); } catch (Exception ex) { return(ResponseGenerator.GenerateByException(ex)); } }
public Response Execute(Request request) { try { Response response = new Response(); SetRequestCode(request); Message message = new Message { RequestBody = request.Body, RequestCodeId = request.Code, ExternalSystemId = _externalSystem.Id, RequestUser = request.UserName, IsSyncRequest = true }; _dbContext.Messages.Add(message); _dbContext.SaveChanges(); using (RabbitClient client = new RabbitClient()) { client.Execute(message.RequestCodeId, message.Id); } _dbContext.Entry(message).Reload(); response = new Response { Id = message.Id, Body = message.ResponseBody }; if (!string.IsNullOrEmpty(message.ErrorMessage)) { response.IsError = true; response.Error = message.ErrorMessage; } return(response); } catch (Exception ex) { return(ResponseGenerator.GenerateByException(ex)); } }
public Response GetResponse(Guid requestId) { Response resultResponse = new ResponseGenerator(_dbContext, requestId).GenerateByMessageAndRequestId(); return(resultResponse); }