public void Execute() { try { var response = _func.Invoke(_envelope); _request.SetResponse(response); } catch (Exception e) { _request.SetError(e); } }
public void Request <TRequest, TResponse>(string topic, Envelope <TRequest> envelope, IResponseReceiver <TResponse> request) { Assert.ArgumentNotNull(envelope, nameof(envelope)); Assert.ArgumentNotNull(request, nameof(request)); var topicEnvelope = envelope.RedirectToTopic(topic); var listener = _store.GetListener <TRequest, TResponse>(topic); if (listener == null) { _logger.Debug($"No listener configured for RequestType={typeof(TRequest).Name} ResponseType={typeof(TResponse).Name} Topic={topic}"); request.SetNoResponse(); return; } if (!listener.CanHandle(envelope)) { request.SetNoResponse(); return; } _logger.Debug("Requesting RequestType={0} ResponseType={1} Topic={2} to listener Id={3}", typeof(TRequest).FullName, typeof(TResponse).FullName, envelope.Topics.FirstOrDefault(), listener.Id); try { listener.Request(topicEnvelope, request); } catch (Exception e) { _logger.Error($"Error on request Type={typeof(TRequest).FullName}, {typeof(TResponse).FullName} Topic={topic}, Listener Id={listener.Id}: {e.Message}\n{e.StackTrace}"); request.SetError(e); } if (listener.ShouldStopListening) { _store.RemoveListener(topic, listener); } }
public void Request(Envelope <int> envelope, IResponseReceiver <int> request) { request.SetError(new Exception("Should not get here")); }
public void SetError(Exception e) { _circuitBreaker.RecordResult(false); _inner.SetError(e); }