private async Task OnExecuteAsync( IMediator mediator, IMapper mapper, IConsole console, IMessageReceiverAccessor messageReceiverAccessor, ISerializer serializer, Receive.Request request) { if (messageReceiverAccessor.MessageReceiver == null) { console.WriteLine($"QueueClient is null, did you forget to call service-bus-settings"); return; } var command = mapper.Map(this, request); console.WriteLine($"Sending Request...."); var response = await mediator.Send(command); if (response.Exception != null) { console.WriteLine($"{response.Exception.Message}"); } else { if (response.Result == null) { console.WriteLine($"Success: No Messages Available......"); } else { try { var json = Encoding.UTF8.GetString(response.Result.Body); var job = serializer.Deserialize <Job>(json); // json = job.ToJson(); var jobMessage = new JobMessage { Job = job, Message = response.Result }; json = jobMessage.ToJson(true); Console.WriteLine(json); } catch (Exception ex) { console.WriteLine($"Success: Got message......but failed to Deserialize\n{ex.Message}"); } } } }
public Request(IMessageReceiverAccessor messageReceiverAccessor) { MessageReceiver = messageReceiverAccessor.MessageReceiver; }