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

            GetOrAddPayload<BrokeredMessageContext>(() => this);
        }
 public MessageReceiverFilter(IPipe <ReceiveContext> receivePipe, IReceiveObserver receiveObserver, IReceiveEndpointObserver endpointObserver, ITaskSupervisor supervisor)
 {
     _receivePipe      = receivePipe;
     _receiveObserver  = receiveObserver;
     _endpointObserver = endpointObserver;
     _supervisor       = supervisor;
 }
        /// <summary>
        /// The basic consumer receives messages pushed from the broker.
        /// </summary>
        /// <param name="session">The model context for the consumer</param>
        /// <param name="messageConsumer"></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="context">The topology</param>
        /// <param name="deadLetterTransport"></param>
        /// <param name="errorTransport"></param>
        public ActiveMqBasicConsumer(SessionContext session, IMessageConsumer messageConsumer, Uri inputAddress, IPipe <ReceiveContext> receivePipe,
                                     IReceiveObserver receiveObserver, ActiveMqReceiveEndpointContext context,
                                     IDeadLetterTransport deadLetterTransport, IErrorTransport errorTransport)
        {
            _session             = session;
            _messageConsumer     = messageConsumer;
            _inputAddress        = inputAddress;
            _receivePipe         = receivePipe;
            _receiveObserver     = receiveObserver;
            _context             = context;
            _deadLetterTransport = deadLetterTransport;
            _errorTransport      = errorTransport;

            _tracker = new DeliveryTracker(HandleDeliveryComplete);

            _receiveSettings = session.GetPayload <ReceiveSettings>();

            _pending = new ConcurrentDictionary <string, ActiveMqReceiveContext>();

            _deliveryComplete = new TaskCompletionSource <bool>();

            messageConsumer.Listener += HandleMessage;

            SetReady();
        }
示例#4
0
 public HttpSendTransportProvider(BusHostCollection <HttpHost> hosts, IReceivePipe receivePipe, IReceiveObserver receiveObserver, IReceiveEndpointTopology topology)
 {
     _hosts           = hosts;
     _receivePipe     = receivePipe;
     _receiveObserver = receiveObserver;
     _topology        = topology;
 }
示例#5
0
 public HttpSendTransport(ClientCache clientCache, HttpSendSettings sendSettings, IReceiveObserver receiveObserver)
 {
     _clientCache     = clientCache;
     _sendSettings    = sendSettings;
     _receiveObserver = receiveObserver;
     _observers       = new SendObservable();
 }
示例#6
0
        public Receiver(MessageReceiver messageReceiver, Uri inputAddress, IPipe <ReceiveContext> receivePipe, ReceiveSettings receiveSettings,
                        IReceiveObserver receiveObserver, ITaskSupervisor supervisor)
        {
            _messageReceiver = messageReceiver;
            _inputAddress    = inputAddress;
            _receivePipe     = receivePipe;
            _receiveSettings = receiveSettings;
            _receiveObserver = receiveObserver;
            _supervisor      = supervisor;

            _participant = supervisor.CreateParticipant();

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

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

                _participant.SetComplete();
            };

            messageReceiver.OnMessageAsync(OnMessage, options);

            _participant.SetReady();

            SetupStopTask();
        }
示例#7
0
        public EventDataReceiveContext(Uri inputAddress, EventData message, IReceiveObserver observer, ReceiveEndpointContext receiveEndpointContext)
            : base(inputAddress, false, observer, receiveEndpointContext)
        {
            _message = message;

            GetOrAddPayload <EventDataContext>(() => this);
        }
示例#8
0
        public ServiceBusReceiveContext(Uri inputAddress, BrokeredMessage message, IReceiveObserver observer, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider)
            : base(inputAddress, message.DeliveryCount > 1, observer, sendEndpointProvider, publishEndpointProvider)
        {
            _message = message;

            GetOrAddPayload <BrokeredMessageContext>(() => this);
        }
示例#9
0
        public ServiceBusReceiveContext(Uri inputAddress, BrokeredMessage message, IReceiveObserver observer)
            : base(inputAddress, message.DeliveryCount > 1, observer)
        {
            _message = message;

            GetOrAddPayload <BrokeredMessageContext>(() => this);
        }
示例#10
0
        public Receiver(MessageReceiver messageReceiver, Uri inputAddress, IPipe<ReceiveContext> receivePipe, ReceiveSettings receiveSettings,
            IReceiveObserver receiveObserver, ITaskSupervisor supervisor)
        {
            _messageReceiver = messageReceiver;
            _inputAddress = inputAddress;
            _receivePipe = receivePipe;
            _receiveSettings = receiveSettings;
            _receiveObserver = receiveObserver;
            _supervisor = supervisor;

            _participant = supervisor.CreateParticipant();

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

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

                _participant.SetComplete();
            };

            messageReceiver.OnMessageAsync(OnMessage, options);

            _participant.SetReady();

            SetupStopTask();
        }
        public ServiceBusReceiveContext(Uri inputAddress, BrokeredMessage message, IReceiveObserver observer, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider)
            : base(inputAddress, message.DeliveryCount > 1, observer, sendEndpointProvider, publishEndpointProvider)
        {
            _message = message;

            GetOrAddPayload<BrokeredMessageContext>(() => this);
        }
        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);
        }
示例#13
0
        public HttpReceiveContext(HttpContext httpContext, bool redelivered, IReceiveObserver receiveObserver, ReceiveEndpointContext topology)
            : base(new Uri(httpContext.Request.GetDisplayUrl()), redelivered, receiveObserver, topology)
        {
            _httpContext = httpContext;

            HeaderProvider = new HttpHeaderProvider(httpContext.Request.Headers);
        }
        public HttpReceiveContext(IOwinContext requestContext, bool redelivered, IReceiveObserver receiveObserver,
                                  ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider)
            : base(requestContext.Request.Uri, redelivered, receiveObserver, sendEndpointProvider, publishEndpointProvider)
        {
            _requestContext = requestContext;

            HeaderProvider = new HttpHeaderProvider(requestContext.Request.Headers);
        }
        public ServiceBusReceiveContext(Uri inputAddress, Message message, IReceiveObserver observer,
                                        ReceiveEndpointContext receiveEndpointContext)
            : base(inputAddress, message.SystemProperties.DeliveryCount > 1, observer, receiveEndpointContext)
        {
            _message = message;

            GetOrAddPayload <BrokeredMessageContext>(() => this);
        }
        public InMemoryReceiveContext(Uri inputAddress, InMemoryTransportMessage message, IReceiveObserver observer)
            : base(inputAddress, message.DeliveryCount > 0, observer)
        {
            _body = message.Body;
            _message = message;

            GetOrAddPayload(() => this);
        }
示例#17
0
 public RabbitMqConsumerFilter(IPipe <ReceiveContext> receivePipe, IReceiveObserver receiveObserver, IReceiveTransportObserver transportObserver, ITaskSupervisor supervisor, IReceiveEndpointTopology topology)
 {
     _receivePipe       = receivePipe;
     _receiveObserver   = receiveObserver;
     _transportObserver = transportObserver;
     _supervisor        = supervisor;
     _topology          = topology;
 }
 public RabbitMqConsumerFilter(IPipe <ReceiveContext> receivePipe, IReceiveObserver receiveObserver, IReceiveEndpointObserver endpointObserver,
                               ITaskSupervisor taskSupervisor)
 {
     _receivePipe      = receivePipe;
     _receiveObserver  = receiveObserver;
     _endpointObserver = endpointObserver;
     _taskSupervisor   = taskSupervisor;
 }
        public HttpReceiveContext(IOwinContext requestContext, bool redelivered, IReceiveObserver receiveObserver,
            ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider)
            : base(requestContext.Request.Uri, redelivered, receiveObserver, sendEndpointProvider, publishEndpointProvider)
        {
            _requestContext = requestContext;

            HeaderProvider = new HttpHeaderProvider(requestContext.Request.Headers);
        }
示例#20
0
 public HttpSendTransport(IClientCache clientCache, HttpSendSettings sendSettings, IReceiveObserver receiveObserver, ReceiveEndpointContext topology)
 {
     _clientCache     = clientCache;
     _sendSettings    = sendSettings;
     _receiveObserver = receiveObserver;
     _topology        = topology;
     _observers       = new SendObservable();
 }
示例#21
0
 public HttpSendTransportProvider(IHttpBusConfiguration busConfiguration, IReceivePipe receivePipe, IReceiveObserver receiveObserver,
                                  ReceiveEndpointContext topology)
 {
     _busConfiguration = busConfiguration;
     _receivePipe      = receivePipe;
     _receiveObserver  = receiveObserver;
     _topology         = topology;
 }
        public InMemoryReceiveContext(Uri inputAddress, InMemoryTransportMessage message, IReceiveObserver observer, ISendEndpointProvider sendEndpointProvider,
            IPublishEndpointProvider publishEndpointProvider)
            : base(inputAddress, message.DeliveryCount > 0, observer, sendEndpointProvider, publishEndpointProvider)
        {
            _body = message.Body;
            _message = message;

            GetOrAddPayload(() => this);
        }
        /// <summary>
        /// Adds a RabbitMQ Basic Consumer to the pipeline
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="pipe"></param>
        /// <param name="settings"></param>
        /// <param name="receiveObserver"></param>
        /// <param name="endpointObserver"></param>
        /// <param name="exchangeBindings"></param>
        /// <param name="taskSupervisor"></param>
        /// <param name="mediator"></param>
        public static void RabbitMqConsumer(this IPipeConfigurator<ConnectionContext> configurator, IPipe<ReceiveContext> pipe, ReceiveSettings settings, IReceiveObserver receiveObserver, IReceiveEndpointObserver endpointObserver, IEnumerable<ExchangeBindingSettings> exchangeBindings, ITaskSupervisor taskSupervisor, Mediator<ISetPrefetchCount> mediator)
        {
            if (configurator == null)
                throw new ArgumentNullException(nameof(configurator));

            var pipeBuilderConfigurator = new RabbitMqConsumerPipeSpecification(pipe, settings, receiveObserver, endpointObserver, exchangeBindings, taskSupervisor, mediator);

            configurator.AddPipeSpecification(pipeBuilderConfigurator);
        }
        public HttpClientReceiveContext(HttpResponseMessage responseMessage, Stream responseStream, bool redelivered, IReceiveObserver receiveObserver,
            ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider)
            : base(responseMessage.RequestMessage.RequestUri, redelivered, receiveObserver, sendEndpointProvider, publishEndpointProvider)
        {
            _responseMessage = responseMessage;
            _responseStream = responseStream;

            HeaderProvider = new HttpClientHeaderProvider(responseMessage.Headers);
        }
示例#25
0
        public ConnectHandle ConnectReceiveObserver(IReceiveObserver observer)
        {
            if (_host == null)
            {
                throw new InvalidOperationException("The host is not ready.");
            }

            return(_host.ConnectReceiveObserver(observer));
        }
示例#26
0
 public ServiceBusNamespaceContext(IServiceBusHost host, IReceiveObserver receiveObserver, IReceiveTransportObserver receiveTransportObserver,
                                   TaskSupervisor supervisor)
     : base(new PayloadCache(), supervisor.StoppingToken)
 {
     _host                     = host;
     _receiveObserver          = receiveObserver;
     _receiveTransportObserver = receiveTransportObserver;
     _supervisor               = supervisor;
 }
 public RabbitMqConsumerPipeSpecification(IPipe <ReceiveContext> receivePipe, ReceiveSettings settings, IReceiveObserver receiveObserver, IReceiveEndpointObserver endpointObserver, IEnumerable <ExchangeBindingSettings> exchangeBindings, ITaskSupervisor taskSupervisor)
 {
     _settings         = settings;
     _receiveObserver  = receiveObserver;
     _endpointObserver = endpointObserver;
     _taskSupervisor   = taskSupervisor;
     _exchangeBindings = exchangeBindings.ToArray();
     _receivePipe      = receivePipe;
 }
示例#28
0
 public RabbitMqConsumerFilter(IPipe <ReceiveContext> receivePipe, IReceiveObserver receiveObserver, IReceiveTransportObserver transportObserver, ITaskSupervisor supervisor, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider)
 {
     _receivePipe             = receivePipe;
     _receiveObserver         = receiveObserver;
     _transportObserver       = transportObserver;
     _supervisor              = supervisor;
     _sendEndpointProvider    = sendEndpointProvider;
     _publishEndpointProvider = publishEndpointProvider;
 }
示例#29
0
 public ActiveMqConsumerFilter(IPipe <ReceiveContext> receivePipe, IReceiveObserver receiveObserver, IReceiveTransportObserver transportObserver,
                               ActiveMqReceiveEndpointContext context, IDeadLetterTransport deadLetterTransport, IErrorTransport errorTransport)
 {
     _receivePipe         = receivePipe;
     _receiveObserver     = receiveObserver;
     _transportObserver   = transportObserver;
     _context             = context;
     _deadLetterTransport = deadLetterTransport;
     _errorTransport      = errorTransport;
 }
示例#30
0
 public HttpConsumerFilter(IPipe <ReceiveContext> receivePipe, IReceiveObserver receiveObserver, IReceiveTransportObserver transportObserver,
                           HttpHostSettings hostSettings, ReceiveSettings receiveSettings, HttpReceiveEndpointContext context)
 {
     _receivePipe       = receivePipe;
     _receiveObserver   = receiveObserver;
     _transportObserver = transportObserver;
     _hostSettings      = hostSettings;
     _receiveSettings   = receiveSettings;
     _context           = context;
 }
        /// <summary>
        /// Adds a RabbitMQ Basic Consumer to the pipeline
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="pipe"></param>
        /// <param name="settings"></param>
        /// <param name="receiveObserver"></param>
        /// <param name="transportObserver"></param>
        /// <param name="exchangeBindings"></param>
        /// <param name="supervisor"></param>
        /// <param name="managementPipe"></param>
        /// <param name="sendEndpointProvider"></param>
        /// <param name="publishEndpointProvider"></param>
        /// <param name="host"></param>
        public static void RabbitMqConsumer(this IPipeConfigurator<ConnectionContext> configurator, IPipe<ReceiveContext> pipe, ReceiveSettings settings, IReceiveObserver receiveObserver, IReceiveTransportObserver transportObserver, IEnumerable<ExchangeBindingSettings> exchangeBindings, ITaskSupervisor supervisor, IManagementPipe managementPipe, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider, IRabbitMqHost host)
        {
            if (configurator == null)
                throw new ArgumentNullException(nameof(configurator));

            var pipeBuilderConfigurator = new RabbitMqConsumerPipeSpecification(pipe, settings, receiveObserver, transportObserver, exchangeBindings,
                supervisor, managementPipe, sendEndpointProvider, publishEndpointProvider, host);

            configurator.AddPipeSpecification(pipeBuilderConfigurator);
        }
示例#32
0
        public HttpConsumer(IReceiveObserver receiveObserver, HttpHostSettings settings, IPipe <ReceiveContext> receivePipe, HttpReceiveEndpointContext context)
        {
            _receiveObserver = receiveObserver;
            _receivePipe     = receivePipe;
            _context         = context;

            _tracker          = new DeliveryTracker(OnDeliveryComplete);
            _inputAddress     = settings.GetInputAddress();
            _deliveryComplete = new TaskCompletionSource <bool>();

            SetReady();
        }
        public RabbitMqReceiveContext(Uri inputAddress, string exchange, string routingKey, string consumerTag, ulong deliveryTag, byte[] body, bool redelivered,
            IBasicProperties properties, IReceiveObserver observer, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider)
            : base(inputAddress, redelivered, observer, sendEndpointProvider, publishEndpointProvider)
        {
            Exchange = exchange;
            RoutingKey = routingKey;
            ConsumerTag = consumerTag;
            DeliveryTag = deliveryTag;
            _body = body;
            Properties = properties;

            ((ReceiveContext)this).GetOrAddPayload<RabbitMqBasicConsumeContext>(() => this);
        }
        /// <summary>
        /// Adds a RabbitMQ Basic Consumer to the pipeline
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="receivePipe"></param>
        /// <param name="settings"></param>
        /// <param name="receiveSettings"></param>
        /// <param name="receiveObserver"></param>
        /// <param name="receiveTransportObserver"></param>
        /// <param name="supervisor"></param>
        /// <param name="topology"></param>
        public static void HttpConsumer(this IPipeConfigurator <OwinHostContext> configurator, IPipe <ReceiveContext> receivePipe, HttpHostSettings settings,
                                        ReceiveSettings receiveSettings, IReceiveObserver receiveObserver, IReceiveTransportObserver receiveTransportObserver, ITaskSupervisor supervisor, IHttpReceiveEndpointTopology topology)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var pipeBuilderConfigurator = new HttpConsumerPipeSpecification(settings, receiveSettings, receivePipe, receiveObserver, receiveTransportObserver,
                                                                            supervisor, topology);

            configurator.AddPipeSpecification(pipeBuilderConfigurator);
        }
 public RabbitMqConsumerPipeSpecification(IPipe <ReceiveContext> receivePipe, ReceiveSettings settings, IReceiveObserver receiveObserver,
                                          IReceiveEndpointObserver endpointObserver, IEnumerable <ExchangeBindingSettings> exchangeBindings, ITaskSupervisor supervisor,
                                          Mediator <ISetPrefetchCount> mediator)
 {
     _settings         = settings;
     _receiveObserver  = receiveObserver;
     _endpointObserver = endpointObserver;
     _supervisor       = supervisor;
     _exchangeBindings = exchangeBindings.ToArray();
     _receivePipe      = receivePipe;
     _mediator         = mediator;
     _modelSettings    = new RabbitMqModelSettings();
 }
示例#36
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>
        public RabbitMqBasicConsumer(ModelContext model, Uri inputAddress, IPipe <ReceiveContext> receivePipe, IReceiveObserver receiveObserver, ITaskScope taskSupervisor)
        {
            _model           = model;
            _inputAddress    = inputAddress;
            _receivePipe     = receivePipe;
            _receiveObserver = receiveObserver;

            _receiveSettings = model.GetPayload <ReceiveSettings>();

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

            _participant = taskSupervisor.CreateParticipant($"{TypeMetadataCache<RabbitMqBasicConsumer>.ShortName} - {inputAddress}", Stop);
        }
 public RabbitMqReceiveContext(Uri inputAddress, string exchange, string routingKey, string consumerTag, ulong deliveryTag, byte[] body,
                               bool redelivered,
                               IBasicProperties properties, IReceiveObserver observer, RabbitMqReceiveEndpointContext receiveEndpointContext)
     : base(inputAddress, redelivered, observer, receiveEndpointContext)
 {
     Exchange                = exchange;
     RoutingKey              = routingKey;
     ConsumerTag             = consumerTag;
     DeliveryTag             = deliveryTag;
     _body                   = body;
     _receiveEndpointContext = receiveEndpointContext;
     Properties              = properties;
 }
示例#38
0
        public RabbitMqReceiveContext(Uri inputAddress, string exchange, string routingKey, string consumerTag, ulong deliveryTag, byte[] body, bool redelivered,
                                      IBasicProperties properties, IReceiveObserver observer, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider)
            : base(inputAddress, redelivered, observer, sendEndpointProvider, publishEndpointProvider)
        {
            Exchange    = exchange;
            RoutingKey  = routingKey;
            ConsumerTag = consumerTag;
            DeliveryTag = deliveryTag;
            _body       = body;
            Properties  = properties;

            ((ReceiveContext)this).GetOrAddPayload <RabbitMqBasicConsumeContext>(() => this);
        }
 public RabbitMqConsumerPipeSpecification(IPipe <ReceiveContext> receivePipe, ReceiveSettings settings, IReceiveObserver receiveObserver,
                                          IReceiveEndpointObserver endpointObserver, IEnumerable <ExchangeBindingSettings> exchangeBindings, ITaskSupervisor supervisor,
                                          IManagementPipe managementPipe)
 {
     _settings         = settings;
     _receiveObserver  = receiveObserver;
     _endpointObserver = endpointObserver;
     _supervisor       = supervisor;
     _exchangeBindings = exchangeBindings.ToArray();
     _receivePipe      = receivePipe;
     _managementPipe   = managementPipe;
     _modelSettings    = new RabbitMqModelSettings();
 }
示例#40
0
 public RabbitMqConsumerPipeSpecification(IPipe <ReceiveContext> receivePipe, ReceiveSettings settings, IReceiveObserver receiveObserver,
                                          IReceiveTransportObserver transportObserver, ITaskSupervisor supervisor, IConsumePipeConnector managementPipe, IRabbitMqHost host,
                                          IRabbitMqReceiveEndpointTopology topology)
 {
     _settings          = settings;
     _receiveObserver   = receiveObserver;
     _transportObserver = transportObserver;
     _supervisor        = supervisor;
     _receivePipe       = receivePipe;
     _managementPipe    = managementPipe;
     _host     = host;
     _topology = topology;
 }
        /// <summary>
        /// Adds a RabbitMQ Basic Consumer to the pipeline
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="receivePipe"></param>
        /// <param name="settings"></param>
        /// <param name="receiveSettings"></param>
        /// <param name="receiveObserver"></param>
        /// <param name="receiveTransportObserver"></param>
        /// <param name="supervisor"></param>
        /// <param name="sendPipe"></param>
        public static void HttpConsumer(this IPipeConfigurator<OwinHostContext> configurator, IPipe<ReceiveContext> receivePipe, HttpHostSettings settings,
            ReceiveSettings receiveSettings,
            IReceiveObserver receiveObserver, IReceiveTransportObserver receiveTransportObserver, ITaskSupervisor supervisor,
            ISendPipe sendPipe)
        {
            if (configurator == null)
                throw new ArgumentNullException(nameof(configurator));

            var pipeBuilderConfigurator = new HttpConsumerPipeSpecification(settings, receiveSettings, receivePipe, receiveObserver, receiveTransportObserver,
                supervisor, sendPipe);

            configurator.AddPipeSpecification(pipeBuilderConfigurator);
        }
        /// <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>
        public RabbitMqBasicConsumer(ModelContext model, Uri inputAddress, IPipe<ReceiveContext> receivePipe, IReceiveObserver receiveObserver,
            ITaskSupervisor taskSupervisor)
        {
            _model = model;
            _inputAddress = inputAddress;
            _receivePipe = receivePipe;
            _receiveObserver = receiveObserver;

            _receiveSettings = model.GetPayload<ReceiveSettings>();

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

            _participant = taskSupervisor.CreateParticipant();
        }
        /// <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>
        public RabbitMqBasicConsumer(ModelContext model, Uri inputAddress, IPipe<ReceiveContext> receivePipe, IReceiveObserver receiveObserver,
            ITaskScope taskSupervisor)
        {
            _model = model;
            _inputAddress = inputAddress;
            _receivePipe = receivePipe;
            _receiveObserver = receiveObserver;

            _receiveSettings = model.GetPayload<ReceiveSettings>();

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

            _participant = taskSupervisor.CreateParticipant($"{TypeMetadataCache<RabbitMqBasicConsumer>.ShortName} - {inputAddress}", Stop);
            _deliveryComplete = new TaskCompletionSource<bool>();
        }
示例#44
0
        public RabbitMqBasicConsumer(ModelContext model, Uri inputAddress, IPipe<ReceiveContext> receivePipe, IReceiveObserver receiveObserver,
            CancellationToken cancellationToken)
        {
            _model = model;
            _inputAddress = inputAddress;
            _receivePipe = receivePipe;
            _receiveObserver = receiveObserver;

            _receiveSettings = model.GetPayload<ReceiveSettings>();

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

            _consumerComplete = new TaskCompletionSource<RabbitMqConsumerMetrics>();

            _registration = cancellationToken.Register(Complete);
        }
示例#45
0
        public SessionReceiver(QueueClient queueClient, Uri inputAddress, IPipe<ReceiveContext> receivePipe, ReceiveSettings receiveSettings,
            IReceiveObserver receiveObserver, ITaskSupervisor supervisor)
        {
            _queueClient = queueClient;
            _inputAddress = inputAddress;
            _receivePipe = receivePipe;
            _receiveSettings = receiveSettings;
            _receiveObserver = receiveObserver;
            _supervisor = supervisor;

            _participant = supervisor.CreateParticipant();

            var options = new SessionHandlerOptions
            {
                AutoComplete = false,
                AutoRenewTimeout = receiveSettings.AutoRenewTimeout,
                MaxConcurrentSessions = receiveSettings.MaxConcurrentCalls,
                MessageWaitTimeout = receiveSettings.MessageWaitTimeout
            };

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

                if (_currentPendingDeliveryCount == 0)
                {
                    if (_log.IsDebugEnabled)
                        _log.DebugFormat("Session receiver shutdown completed: {0}", _inputAddress);

                    _participant.SetComplete();
                }
            };

            IMessageSessionAsyncHandlerFactory handlerFactory = new MessageSessionAsyncHandlerFactory(supervisor, this);
            queueClient.RegisterSessionHandlerFactoryAsync(handlerFactory, options);

            _participant.SetReady();

            SetupStopTask();
        }
        public HttpConsumerAction(IReceiveObserver receiveObserver,
            HttpHostSettings settings,
            ReceiveSettings receiveSettings,
            IPipe<ReceiveContext> receivePipe,
            ITaskScope taskSupervisor,
            ISendPipe sendPipe)
        {
            _receiveObserver = receiveObserver;
            _receiveSettings = receiveSettings;
            _receivePipe = receivePipe;
            _sendPipe = sendPipe;

            _tracker = new DeliveryTracker(OnDeliveryComplete);
            _inputAddress = settings.GetInputAddress();
            _participant = taskSupervisor.CreateParticipant($"{TypeMetadataCache<HttpConsumerAction>.ShortName} - {_inputAddress}", Stop);
            _deliveryComplete = new TaskCompletionSource<bool>();

            _participant.SetReady();
        }
示例#47
0
        public Receiver(ConnectionContext context, MessageReceiver messageReceiver, Uri inputAddress, IPipe<ReceiveContext> receivePipe, ReceiveSettings receiveSettings,
            IReceiveObserver receiveObserver, ITaskSupervisor supervisor)
        {
            _context = context;
            _messageReceiver = messageReceiver;
            _inputAddress = inputAddress;
            _receivePipe = receivePipe;
            _receiveSettings = receiveSettings;
            _receiveObserver = receiveObserver;

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

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

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

                if (_currentPendingDeliveryCount == 0)
                {
                    if (_log.IsDebugEnabled)
                        _log.DebugFormat("Receiver shutdown completed: {0}", _inputAddress);

                    _participant.SetComplete();
                }
            };

            messageReceiver.OnMessageAsync(OnMessage, options);

            _participant.SetReady();
        }
示例#48
0
        public Receiver(MessageReceiver messageReceiver, Uri inputAddress, IPipe<ReceiveContext> receivePipe,
            ReceiveSettings receiveSettings, IReceiveObserver receiveObserver, CancellationToken cancellationToken)
        {
            _messageReceiver = messageReceiver;
            _inputAddress = inputAddress;
            _receivePipe = receivePipe;
            _receiveSettings = receiveSettings;
            _receiveObserver = receiveObserver;

            _completeTask = new TaskCompletionSource<ReceiverMetrics>();

            _registration = cancellationToken.Register(Shutdown);

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

            options.ExceptionReceived += (sender, x) => _completeTask.TrySetException(x.Exception);

            messageReceiver.OnMessageAsync(OnMessage, options);
        }
 public ConnectHandle ConnectReceiveObserver(IReceiveObserver observer)
 {
     return _receiveObservable.Connect(observer);
 }
 public HttpSendTransportProvider(BusHostCollection<HttpHost> hosts, IReceivePipe receivePipe, IReceiveObserver receiveObserver)
 {
     _hosts = hosts;
     _receivePipe = receivePipe;
     _receiveObserver = receiveObserver;
 }
示例#51
0
 public ConnectHandle ConnectReceiveObserver(IReceiveObserver observer)
 {
     return _receiveTransport.ConnectReceiveObserver(observer);
 }