Example #1
0
        public async Task <TResponse> Request <TResponse>(object request, TimeSpan timeout = default(TimeSpan), Action <Envelope> configure = null)
        {
            var envelope = EnvelopeForRequestResponse <TResponse>(request);

            configure?.Invoke(envelope);

            timeout = timeout == default(TimeSpan) ? 10.Seconds() : timeout;

            var watcher = _watcher.StartWatch <TResponse>(envelope.Id, timeout);

            await _sender.Send(envelope);

            return(await watcher);
        }
Example #2
0
        public async Task <TResponse> Request <TResponse>(object request, RequestOptions options = null)
        {
            options = options ?? new RequestOptions();

            var envelope = EnvelopeForRequestResponse <TResponse>(request);

            if (options.Destination != null)
            {
                envelope.Destination = options.Destination;
            }


            var watcher = _watcher.StartWatch <TResponse>(envelope.CorrelationId, options.Timeout);

            await _sender.Send(envelope);

            return(await watcher);
        }
Example #3
0
        public Task <TResponse> Request <TResponse>(object request, RequestOptions options = null)
        {
            options = options ?? new RequestOptions();

            var envelope = new Envelope
            {
                Message        = request,
                ReplyRequested = typeof(TResponse).Name
            };

            if (options.Destination != null)
            {
                envelope.Destination = options.Destination;
            }


            var task = _watcher.StartWatch <TResponse>(envelope.CorrelationId, options.Timeout);

            _sender.Send(envelope);

            return(task);
        }