Beispiel #1
0
        Task IPipe <SendContext <TRequest> > .Send(SendContext <TRequest> context)
        {
            context.RequestId       = _requestId;
            context.ResponseAddress = _bus.Address;

            if (_requestContext == null)
            {
                _requestContext = new SendRequestContext <TRequest>(_bus, context, _taskScheduler, _callback);
            }
            else
            {
                var publishContext = new PublishRequestContext <TRequest>(_bus, context, _callback, _requestContext.Connections, ((RequestContext <TRequest>)_requestContext).Task);
            }

            return(TaskUtil.Completed);
        }
Beispiel #2
0
        public PublishRequestConfigurator(SendContext <TRequest> context, Action <IRequestConfigurator <TRequest> > callback,
                                          IDictionary <Type, RequestHandlerHandle> connections, Task <TRequest> requestTask)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (!context.RequestId.HasValue)
            {
                throw new ArgumentException("The requestId must be initialized");
            }

            _connections = connections;
            _requestTask = requestTask;
            _context     = context;

            callback(this);
        }
        protected override void Send <T>(SendContext <T> context)
        {
            if (_requestId.HasValue)
            {
                context.RequestId = _requestId;
            }

            if (_consumeContext != null)
            {
                context.TransferConsumeContextHeaders(_consumeContext);

                if (_requestId.HasValue && _consumeContext.ExpirationTime.HasValue &&
                    _consumeContext.ResponseAddress != null && _consumeContext.ResponseAddress == context.DestinationAddress)
                {
                    context.TimeToLive = _consumeContext.ExpirationTime.Value - DateTime.UtcNow;
                    if (context.TimeToLive.Value <= TimeSpan.Zero)
                    {
                        context.TimeToLive = TimeSpan.FromSeconds(1);
                    }
                }
            }
        }
        public Task Send <T>(SendContext <T> context)
            where T : class
        {
            if (_requestId.HasValue)
            {
                context.RequestId = _requestId;
            }

            if (_consumeContext != null)
            {
                context.TransferConsumeContextHeaders(_consumeContext);

                if (_requestId.HasValue && _consumeContext.ExpirationTime.HasValue)
                {
                    context.TimeToLive = _consumeContext.ExpirationTime.Value - DateTime.UtcNow;
                    if (context.TimeToLive.Value <= TimeSpan.Zero)
                    {
                        context.TimeToLive = TimeSpan.FromSeconds(1);
                    }
                }
            }

            return(TaskUtil.Completed);
        }
 protected override void Send(SendContext <TMessage> context)
 {
 }
Beispiel #6
0
 public static void SetCorrelationId(SendContext <T> context)
 {
     Cached.Metadata.Value.SetCorrelationId(context);
 }
Beispiel #7
0
 void IMessageCorrelationCache <T> .SetCorrelationId(SendContext <T> context)
 {
     _setCorrelationIdPipe.Value.SetCorrelationId(context);
 }
Beispiel #8
0
 public MessageSendContextAdapter(SendContext context)
 {
     _context = context;
 }
 public Task Send(SendContext <TMessage> context)
 {
     return(_pipe.IsNotEmpty() ? _pipe.Send(context) : TaskUtil.Completed);
 }
 public SendContextProxy(SendContext context, TMessage message)
     : base(context)
 {
     Message = message;
 }
Beispiel #11
0
 public Task Send(SendContext <TMessage> context)
 {
     return(_pipe?.Send(context) ?? TaskUtil.Completed);
 }
Beispiel #12
0
            public Task Send(SendContext <T> context)
            {
                var publishContext = context.GetPayload <PublishContext <T> >();

                return(_pipe.Send(publishContext));
            }
 public SendContextScope(SendContext context)
     : base(context)
 {
     _context = context;
 }
        public void SetCorrelationId(SendContext <T> context)
        {
            var correlationId = _getCorrelationId(context.Message);

            context.CorrelationId = correlationId;
        }
 public PublishContextProxy(SendContext <T> context)
 {
     _context = context;
 }
            bool IPipeContextConverter <SendContext, SendContext <T> > .TryConvert(SendContext input, out SendContext <T> output)
            {
                output = input as SendContext <T>;

                return(output != null);
            }