internal async Task <SendResponse> Send(SendRequest request, string clientId) { var pbReq = request.ValidateAndComplete(_clientId); var response = new SendResponse(request); _pendingRequests.TryAdd(response.RequestId, response); SendRequest(pbReq); await response.WaitForResponseTask.Task; if (!string.IsNullOrEmpty(response.Error)) { throw new Exception($"send request error: {response.Error}"); } return(response); }
/// <summary> /// Send List of Queue Messages /// </summary> /// <param name="request">Send request object</param> public async Task <SendResponse> Send(SendRequest request) { Upstream upstream; bool connected; lock (_upstream) { upstream = _upstream; connected = _connected; } if (connected && upstream != null) { return(await upstream.Send(request, _clientId)); } else { if (ctx.IsCancellationRequested) { throw new Exception("queue client closed"); } throw new Exception("queue client connection is not ready"); } }