Exemplo n.º 1
0
 public HttpSendTransportProvider(BusHostCollection <HttpHost> hosts, IReceivePipe receivePipe, IReceiveObserver receiveObserver, IReceiveEndpointTopology topology)
 {
     _hosts           = hosts;
     _receivePipe     = receivePipe;
     _receiveObserver = receiveObserver;
     _topology        = topology;
 }
Exemplo n.º 2
0
 public HttpSendTransport(ClientCache clientCache, HttpSendSettings sendSettings, IReceiveObserver receiveObserver, IReceiveEndpointTopology topology)
 {
     _clientCache     = clientCache;
     _sendSettings    = sendSettings;
     _receiveObserver = receiveObserver;
     _topology        = topology;
     _observers       = new SendObservable();
 }
Exemplo n.º 3
0
 public MessageSessionAsyncHandlerFactory(NamespaceContext context, ITaskSupervisor supervisor, ISessionReceiver receiver, IDeliveryTracker tracker, IReceiveEndpointTopology topology)
 {
     _context    = context;
     _supervisor = supervisor;
     _receiver   = receiver;
     _tracker    = tracker;
     _topology   = topology;
 }
Exemplo n.º 4
0
 public RabbitMqConsumerFilter(IPipe <ReceiveContext> receivePipe, IReceiveObserver receiveObserver, IReceiveTransportObserver transportObserver, ITaskSupervisor supervisor, IReceiveEndpointTopology topology)
 {
     _receivePipe       = receivePipe;
     _receiveObserver   = receiveObserver;
     _transportObserver = transportObserver;
     _supervisor        = supervisor;
     _topology          = topology;
 }
Exemplo n.º 5
0
        public HttpClientReceiveContext(HttpResponseMessage responseMessage, Stream responseStream, bool redelivered, IReceiveObserver receiveObserver,
                                        IReceiveEndpointTopology topology)
            : base(responseMessage.RequestMessage.RequestUri, redelivered, receiveObserver, topology)
        {
            _responseMessage = responseMessage;
            _responseStream  = responseStream;

            HeaderProvider = new HttpClientHeaderProvider(responseMessage.Headers);
        }
        public HttpResponseReceiveEndpointTopology(IReceiveEndpointTopology topology, IOwinContext owinContext, ISendPipe sendPipe,
                                                   IMessageSerializer serializer)
        {
            _topology    = topology;
            _owinContext = owinContext;
            _sendPipe    = sendPipe;
            _serializer  = serializer;

            _sendEndpointProvider = new Lazy <ISendEndpointProvider>(CreateSendEndpointProvider);
        }
Exemplo n.º 7
0
        public SessionReceiver(ClientContext clientContext, IPipe <ReceiveContext> receivePipe, ClientSettings clientSettings, ITaskSupervisor supervisor, IReceiveEndpointTopology topology)
        {
            _clientContext  = clientContext;
            _receivePipe    = receivePipe;
            _clientSettings = clientSettings;
            _supervisor     = supervisor;
            _topology       = topology;

            _tracker = new DeliveryTracker(HandleDeliveryComplete);

            _participant = supervisor.CreateParticipant($"{TypeMetadataCache<Receiver>.ShortName} - {clientContext.InputAddress}", Stop);
        }
        public InMemoryReceiveTransport(Uri inputAddress, IInMemoryQueue queue, IReceiveEndpointTopology topology)
        {
            _inputAddress = inputAddress;
            _queue        = queue;
            _topology     = topology;

            _receiveObservable   = new ReceiveObservable();
            _transportObservable = new ReceiveTransportObservable();

            _tracker = new DeliveryTracker(HandleDeliveryComplete);

            _supervisor  = new TaskSupervisor($"{TypeMetadataCache<InMemoryReceiveTransport>.ShortName} - {_inputAddress}");
            _participant = _supervisor.CreateParticipant($"{TypeMetadataCache<InMemoryReceiveTransport>.ShortName} - {_inputAddress}");
        }
Exemplo n.º 9
0
        protected BaseReceiveContext(Uri inputAddress, bool redelivered, IReceiveObserver receiveObserver, CancellationTokenSource source, IReceiveEndpointTopology topology)
            : base(new PayloadCache(), source.Token)
        {
            _receiveTimer = Stopwatch.StartNew();

            _cancellationTokenSource = source;
            Topology         = topology;
            InputAddress     = inputAddress;
            Redelivered      = redelivered;
            _receiveObserver = receiveObserver;

            _headers = new Lazy <Headers>(() => new JsonHeaders(ObjectTypeDeserializer.Instance, HeaderProvider));

            _contentType = new Lazy <ContentType>(GetContentType);

            _pendingTasks = new List <Task>(4);
        }
Exemplo n.º 10
0
        /// <summary>
        /// The basic consumer receives messages pushed from the broker.
        /// </summary>
        /// <param name="model">The model context for the consumer</param>
        /// <param name="inputAddress">The input address for messages received by the consumer</param>
        /// <param name="receivePipe">The receive pipe to dispatch messages</param>
        /// <param name="receiveObserver">The observer for receive events</param>
        /// <param name="taskSupervisor">The token used to cancel/stop the consumer at shutdown</param>
        /// <param name="topology">The topology</param>
        public RabbitMqBasicConsumer(ModelContext model, Uri inputAddress, IPipe <ReceiveContext> receivePipe, IReceiveObserver receiveObserver, ITaskScope taskSupervisor, IReceiveEndpointTopology topology)
        {
            _model           = model;
            _inputAddress    = inputAddress;
            _receivePipe     = receivePipe;
            _receiveObserver = receiveObserver;
            _topology        = topology;

            _tracker = new DeliveryTracker(HandleDeliveryComplete);

            _receiveSettings = model.GetPayload <ReceiveSettings>();

            _pending = new ConcurrentDictionary <ulong, RabbitMqReceiveContext>();

            _participant      = taskSupervisor.CreateParticipant($"{TypeMetadataCache<RabbitMqBasicConsumer>.ShortName} - {inputAddress}", Stop);
            _deliveryComplete = new TaskCompletionSource <bool>();
        }
Exemplo n.º 11
0
        public Receiver(NamespaceContext context, ClientContext clientContext, IPipe <ReceiveContext> receivePipe, ClientSettings clientSettings,
                        ITaskSupervisor supervisor, IReceiveEndpointTopology topology)
        {
            _context        = context;
            _clientContext  = clientContext;
            _receivePipe    = receivePipe;
            _clientSettings = clientSettings;
            _topology       = topology;

            _tracker = new DeliveryTracker(DeliveryComplete);

            _participant = supervisor.CreateParticipant($"{TypeMetadataCache<Receiver>.ShortName} - {clientContext.InputAddress}", Stop);

            var options = new OnMessageOptions
            {
                AutoComplete       = false,
                AutoRenewTimeout   = clientSettings.AutoRenewTimeout,
                MaxConcurrentCalls = clientSettings.MaxConcurrentCalls
            };

            options.ExceptionReceived += (sender, x) =>
            {
                if (!(x.Exception is OperationCanceledException))
                {
                    if (_log.IsErrorEnabled)
                    {
                        _log.Error($"Exception received on receiver: {clientContext.InputAddress} during {x.Action}", x.Exception);
                    }
                }

                if (_tracker.ActiveDeliveryCount == 0)
                {
                    if (_log.IsDebugEnabled)
                    {
                        _log.DebugFormat("Receiver shutdown completed: {0}", clientContext.InputAddress);
                    }

                    _participant.SetComplete();
                }
            };

            clientContext.OnMessageAsync(OnMessage, options);

            _participant.SetReady();
        }
Exemplo n.º 12
0
        public IReceiveTransport GetReceiveTransport(string queueName, IReceiveEndpointTopology topology)
        {
            if (_sendEndpointProvider == null)
            {
                _sendEndpointProvider = topology.SendEndpointProvider;
            }
            if (_publishEndpointProvider == null)
            {
                _publishEndpointProvider = topology.PublishEndpointProvider;
            }
            if (_topology == null)
            {
                _topology = topology;
            }

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Creating receive transport for queue: {0}", queueName);
            }

            var queue = _messageFabric.GetQueue(queueName);

            return(new InMemoryReceiveTransport(new Uri(_baseUri, queueName), queue, topology));
        }
Exemplo n.º 13
0
        public RabbitMqReceiveContext(Uri inputAddress, string exchange, string routingKey, string consumerTag, ulong deliveryTag, byte[] body, bool redelivered,
                                      IBasicProperties properties, IReceiveObserver observer, IReceiveEndpointTopology topology)
            : base(inputAddress, redelivered, observer, topology)
        {
            Exchange    = exchange;
            RoutingKey  = routingKey;
            ConsumerTag = consumerTag;
            DeliveryTag = deliveryTag;
            _body       = body;
            Properties  = properties;

            ((ReceiveContext)this).GetOrAddPayload <RabbitMqBasicConsumeContext>(() => this);
        }
Exemplo n.º 14
0
        public InMemoryReceiveContext(Uri inputAddress, InMemoryTransportMessage message, IReceiveObserver observer, IReceiveEndpointTopology topology)
            : base(inputAddress, message.DeliveryCount > 0, observer, topology)
        {
            _body    = message.Body;
            _message = message;

            GetOrAddPayload(() => this);
        }
        public ServiceBusReceiveContext(Uri inputAddress, BrokeredMessage message, IReceiveObserver observer, IReceiveEndpointTopology topology)
            : base(inputAddress, message.DeliveryCount > 1, observer, topology)
        {
            _message = message;

            GetOrAddPayload <BrokeredMessageContext>(() => this);
        }
Exemplo n.º 16
0
 protected BaseReceiveContext(Uri inputAddress, bool redelivered, IReceiveObserver receiveObserver, IReceiveEndpointTopology topology)
     : this(inputAddress, redelivered, receiveObserver, new CancellationTokenSource(), topology)
 {
 }
Exemplo n.º 17
0
        public HttpReceiveContext(IOwinContext requestContext, bool redelivered, IReceiveObserver receiveObserver, IReceiveEndpointTopology topology)
            : base(requestContext.Request.Uri, redelivered, receiveObserver, topology)
        {
            _requestContext = requestContext;

            HeaderProvider = new HttpHeaderProvider(requestContext.Request.Headers);
        }
Exemplo n.º 18
0
 public MessageSessionReceiverFilter(IPipe <ReceiveContext> receivePipe, IReceiveEndpointTopology topology)
 {
     _receivePipe = receivePipe;
     _topology    = topology;
 }