/// <summary> /// Publish a single request using the KubeMQ , response will return in the passed handler. /// </summary> /// <param name="handler">Method that will be activated once receiving response.</param> /// <param name="request">The KubeMQ.SDK.csharp.RequestReply.LowLevel.request that will be sent to the kubeMQ.</param> /// <returns>A task that represents the request that was sent using the SendRequest.</returns> public async Task SendRequest(Request request, HandleResponseDelegate handler) { try { //LogRequest(request); InnerRequest innerRequest = request.Convert(); // Send request and wait for response InnerResponse innerResponse = await GetKubeMQClient().SendRequestAsync(innerRequest, Metadata); // convert InnerResponse to Response and return response to end user Response response = new Response(innerResponse); // send the response to the end-user response handler handler(response); } catch (RpcException ex) { logger.LogError($"Grpc Exception in SendRequest. Status: {ex.Status}"); throw new RpcException(ex.Status); } catch (Exception ex) { logger.LogError(ex, "Exception in Initiator.SendRequest"); throw ex; } }
/// <summary> /// Publish a single request using the KubeMQ. /// </summary> /// <param name="request"></param> /// <returns>KubeMQ KubeMQ.SDK.csharp.RequestReply.Response.</returns> public Response SendRequest(Request request) { try { //LogRequest(request); InnerRequest innerRequest = request.Convert(); // Send request and wait for response InnerResponse innerResponse = GetKubeMQClient().SendRequest(innerRequest, Metadata); // convert InnerResponse to Response and return response to end user return(new Response(innerResponse)); } catch (RpcException ex) { logger.LogError($"Grpc Exception in SendRequestAsync. Status: {ex.Status}"); throw new RpcException(ex.Status); } catch (Exception ex) { logger.LogError(ex, "Exception in Initiator.SendRequestAsync"); return(null); } }