public ReceiveTransportHandle Start(IPipe<ReceiveContext> receivePipe)
        {
            if (_log.IsDebugEnabled)
                _log.DebugFormat("Starting receive transport: {0}", new Uri(_host.Settings.ServiceUri, _settings.QueueDescription.Path));

            var supervisor =
                new TaskSupervisor($"{TypeMetadataCache<ServiceBusReceiveTransport>.ShortName} - {_host.Settings.GetInputAddress(_settings.QueueDescription)}");

            IPipe<ConnectionContext> connectionPipe = Pipe.New<ConnectionContext>(x =>
            {
                x.UseFilter(new PrepareReceiveQueueFilter(_settings, _subscriptionSettings));

                if (_settings.QueueDescription.RequiresSession)
                {
                    x.UseFilter(new MessageSessionReceiverFilter(receivePipe, _receiveObservers, _endpointObservers, supervisor));
                }
                else
                {
                    x.UseFilter(new MessageReceiverFilter(receivePipe, _receiveObservers, _endpointObservers, supervisor));
                }
            });

            Receiver(connectionPipe, supervisor);

            return new Handle(supervisor);
        }
Esempio n. 2
0
        Task SendUsingNewConnection(IPipe<OwinHostContext> connectionPipe, OwinHostScope scope, CancellationToken stoppingToken)
        {
            try
            {
                if (_cacheTaskScope.StoppingToken.IsCancellationRequested)
                    throw new TaskCanceledException($"The connection is being disconnected: {_settings.ToDebugString()}");

                if (_log.IsDebugEnabled)
                    _log.DebugFormat("Connecting: {0}", _settings.ToDebugString());
                
                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("Connected: {0} (address: {1}, local: {2}", _settings.ToDebugString(),
                        _settings.Host, _settings.Port);
                }

                var hostContext = new HttpOwinHostContext(_settings, _cacheTaskScope);

                hostContext.GetOrAddPayload(() => _settings);

                scope.Connected(hostContext);
            }
            catch (Exception ex)
            {
                Interlocked.CompareExchange(ref _scope, null, scope);

                scope.ConnectFaulted(ex);

                throw new HttpConnectionException("Connect failed: " + _settings.ToDebugString(), ex);
            }

            return SendUsingExistingConnection(connectionPipe, scope, stoppingToken);
        }
        public void ProcessHandshake(int TimeOut, ref IPipe pipe)
        {
            //usar un waithandle por cada tipo de handshake.
            //Estos waithandles seran liberados cuando la maquina de estados
            //alcance un estado que libere el wait handle.

            try
            {
                LogCurrentState();
                LogSession.LogMessage("Processing Handshake @ WEIGHT Station...");
                this.Workflow.Start();

                //if (!this.Workflow.WaitForResult(TimeOut))
                //{
                //    throw new TimeoutException("Timeout waiting for StableState");
                //}
                LogSession.LogMessage("Weight Workflow Done");
                this.Workflow.Reset();
            }
            catch (Exception exception)
            {
                LogSession.LogException(exception);
                throw exception;
            }
        }
Esempio n. 4
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();
        }
        async void Receiver(IPipe<ConnectionContext> transportPipe, TaskSupervisor supervisor)
        {
            await Repeat.UntilCancelled(supervisor.StopToken, async () =>
            {
                try
                {
                    await _host.ConnectionCache.Send(transportPipe, supervisor.StopToken).ConfigureAwait(false);
                }
                catch (RabbitMqConnectionException ex)
                {
                    if (_log.IsErrorEnabled)
                        _log.ErrorFormat("RabbitMQ connection failed: {0}", ex.Message);

                    var inputAddress = _host.Settings.GetInputAddress(_settings);

                    await _endpointObservers.Faulted(new Faulted(inputAddress, ex)).ConfigureAwait(false);
                }
                catch (TaskCanceledException)
                {
                }
                catch (Exception ex)
                {
                    if (_log.IsErrorEnabled)
                        _log.ErrorFormat("RabbitMQ receive transport failed: {0}", ex.Message);

                    var inputAddress = _host.Settings.GetInputAddress(_settings);

                    await _endpointObservers.Faulted(new Faulted(inputAddress, ex)).ConfigureAwait(false);
                }
            }).ConfigureAwait(false);
        }
Esempio n. 6
0
 public void HandleMessage(object message, IPipe pipe)
 {
     lock (this) {
         this.lastMessage = message;
     }
     waiter.Set();
 }
Esempio n. 7
0
 public PipeInstancesAddedEventArgs(IPipe[] pipes)
 {
     if (pipes == null)
         _Pipes = new IPipe[0];
     else
         _Pipes = pipes;
 }
Esempio n. 8
0
 public void HandleMessage(object message, IPipe pipe)
 {
     //TODO handle message in another thread using a queue
     foreach (IHandler handler in handlers)
     {
         handler.HandleMessage(message, this);
     }
 }
Esempio n. 9
0
		/// <summary>
		/// Initializes a new instance of the <see cref="BroadcastStream"/> class.
		/// </summary>
		/// <param name="name">The stream name.</param>
		/// <param name="scope">The stream scope.</param>
		public BroadcastStream(String name, IScope scope) {
			_name = name;
			_scope = scope;
			_livePipe = null;
			// We want to create a video codec when we get our first video packet.
			_codecInfo = new StreamCodecInfo();
			_creationTime = -1;
		}
        Task SendUsingNewConnection(IPipe<ConnectionContext> connectionPipe, ConnectionScope scope, CancellationToken cancellationToken)
        {
            try
            {
                if (_cacheTaskScope.StoppingToken.IsCancellationRequested)
                    throw new TaskCanceledException($"The connection is being disconnected: {_settings.ToDebugString()}");

                if (_log.IsDebugEnabled)
                    _log.DebugFormat("Connecting: {0}", _settings.ToDebugString());

                IConnection connection;
                if (_settings.ClusterMembers?.Any() ?? false)
                {
                    connection = _connectionFactory.CreateConnection(_settings.ClusterMembers, _settings.ClientProvidedName);
                }
                else
                {
                    var hostNames = Enumerable.Repeat(_settings.Host, 1).ToList();

                    connection = _connectionFactory.CreateConnection(hostNames, _settings.ClientProvidedName);
                }


                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("Connected: {0} (address: {1}, local: {2}", _settings.ToDebugString(),
                        connection.Endpoint, connection.LocalPort);
                }

                EventHandler<ShutdownEventArgs> connectionShutdown = null;
                connectionShutdown = (obj, reason) =>
                {
                    Interlocked.CompareExchange(ref _scope, null, scope);

                    scope.Shutdown(reason.ReplyText);

                    connection.ConnectionShutdown -= connectionShutdown;
                };

                connection.ConnectionShutdown += connectionShutdown;

                var connectionContext = new RabbitMqConnectionContext(connection, _settings, _cacheTaskScope);

                connectionContext.GetOrAddPayload(() => _settings);

                scope.Connected(connectionContext);
            }
            catch (BrokerUnreachableException ex)
            {
                Interlocked.CompareExchange(ref _scope, null, scope);

                scope.ConnectFaulted(ex);

                throw new RabbitMqConnectionException("Connect failed: " + _settings.ToDebugString(), ex);
            }

            return SendUsingExistingConnection(connectionPipe, scope, cancellationToken);
        }
Esempio n. 11
0
        public static void AddPipe(IPipe pipe)
        {
            if (Pipeline.Any(existingPipe => existingPipe.GetType() == pipe.GetType()))
            {
                return;
            }

            Pipeline.Add(pipe);
        }
Esempio n. 12
0
		public static void AddPipe(IPipe pipe)
		{
			foreach( var existingPipe in _pipeline )
			{
				if( existingPipe.GetType () == pipe.GetType () )
					return;
			}
			_pipeline.Add (pipe);
		}
        public void CopyToArrayCopiesZeroPipesToArrayIfNoneAreSelected()
        {
            Guid[] ids = InitializeTestEntries(3);

            IPipe[] arr = new IPipe[0];

            _selected.CopyTo(arr, 0);
            Assert.Equal(0, arr.Length);
        }
        /// <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);
        }
        /// <summary>
        /// Rescue exceptions via the alternate pipe
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="rescuePipe"></param>
        public static void UseDeadLetterQueue(this IPipeConfigurator<ReceiveContext> configurator, IPipe<ReceiveContext> rescuePipe)
        {
            if (configurator == null)
                throw new ArgumentNullException(nameof(configurator));

            var rescueConfigurator = new DeadLetterPipeSpecification(rescuePipe);

            configurator.AddPipeSpecification(rescueConfigurator);
        }
Esempio n. 16
0
        async Task SendUsingNewModel(IPipe<ModelContext> modelPipe, ModelScope scope, CancellationToken cancellationToken)
        {
            IPipe<ConnectionContext> connectionPipe = Pipe.ExecuteAsync<ConnectionContext>(async connectionContext =>
            {
                IModel model = await connectionContext.CreateModel().ConfigureAwait(false);

                EventHandler<ShutdownEventArgs> modelShutdown = null;
                modelShutdown = (obj, reason) =>
                {
                    model.ModelShutdown -= modelShutdown;

                    Interlocked.CompareExchange(ref _scope, null, scope);

                    scope.Close();
                };

                model.ModelShutdown += modelShutdown;

                var modelContext = new RabbitMqModelContext(connectionContext, model, connectionContext.CancellationToken);

                scope.Connected(modelContext);

                try
                {
                    using (SharedModelContext context = await scope.Attach(cancellationToken).ConfigureAwait(false))
                    {
                        await modelPipe.Send(context).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    if (_log.IsDebugEnabled)
                        _log.Debug("The existing model usage threw an exception", ex);

                    Interlocked.CompareExchange(ref _scope, null, scope);

                    scope.Close();

                    throw;
                }
            });

            try
            {
                await _connectionCache.Send(connectionPipe, new CancellationToken()).ConfigureAwait(false);
            }
            catch (Exception exception)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The connection threw an exception", exception);

                Interlocked.CompareExchange(ref _scope, null, scope);

                throw;
            }
        }
        /// <summary>
        /// Rescue exceptions via the alternate pipe
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="rescuePipe"></param>
        /// <param name="exceptionFilter"></param>
        public static void UseRescue(this IPipeConfigurator<ReceiveContext> configurator, IPipe<ExceptionReceiveContext> rescuePipe,
            IPolicyExceptionFilter exceptionFilter = null)
        {
            if (configurator == null)
                throw new ArgumentNullException(nameof(configurator));

            var rescueConfigurator = new ReceiveContextRescuePipeSpecification(rescuePipe, exceptionFilter);

            configurator.AddPipeSpecification(rescueConfigurator);
        }
        /// <summary>
        /// Start the receive transport, returning a Task that can be awaited to signal the transport has 
        /// completely shutdown once the cancellation token is cancelled.
        /// </summary>
        /// <param name="receivePipe"></param>
        /// <returns>A task that is completed once the transport is shut down</returns>
        public ReceiveTransportHandle Start(IPipe<ReceiveContext> receivePipe)
        {
            var stopTokenSource = new CancellationTokenSource();

            IPipe<ConnectionContext> pipe = Pipe.New<ConnectionContext>(x => x.RabbitMqConsumer(receivePipe, _settings, _receiveObservers, _endpointObservers, _exchangeBindings));

            Task receiverTask = Receiver(pipe, stopTokenSource.Token);

            return new Handle(stopTokenSource, receiverTask);
        }
        /// <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);
        }
Esempio n. 20
0
        async Task SendUsingNewModel(IPipe<ModelContext> modelPipe, ModelScope scope, CancellationToken cancellationToken)
        {
            IPipe<ConnectionContext> connectionPipe = Pipe.ExecuteAsync<ConnectionContext>(async connectionContext =>
            {
                try
                {
                    if (_log.IsDebugEnabled)
                        _log.DebugFormat("Creating model: {0}", connectionContext.HostSettings.ToDebugString());

                    var model = await connectionContext.CreateModel().ConfigureAwait(false);

                    EventHandler<ShutdownEventArgs> modelShutdown = null;
                    modelShutdown = (obj, reason) =>
                    {
                        model.ModelShutdown -= modelShutdown;

                        Interlocked.CompareExchange(ref _scope, null, scope);

                        scope.Shutdown(reason.ReplyText);
                    };

                    model.ModelShutdown += modelShutdown;

                    var modelContext = new RabbitMqModelContext(connectionContext, model, _cacheTaskScope, _modelSettings);

                    scope.Created(modelContext);
                }
                catch (Exception ex)
                {
                    Interlocked.CompareExchange(ref _scope, null, scope);

                    scope.CreateFaulted(ex);

                    throw;
                }

                await SendUsingExistingModel(modelPipe, scope, cancellationToken).ConfigureAwait(false);
            });

            try
            {
                await _connectionCache.Send(connectionPipe, _cacheTaskScope.StoppedToken).ConfigureAwait(false);
            }
            catch (Exception exception)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The connection threw an exception", exception);

                Interlocked.CompareExchange(ref _scope, null, scope);

                scope.CreateFaulted(exception);

                throw;
            }
        }
        /// <summary>
        /// Start the receive transport, returning a Task that can be awaited to signal the transport has 
        /// completely shutdown once the cancellation token is cancelled.
        /// </summary>
        /// <param name="receivePipe"></param>
        /// <returns>A task that is completed once the transport is shut down</returns>
        public ReceiveTransportHandle Start(IPipe<ReceiveContext> receivePipe)
        {
            var supervisor = new TaskSupervisor();

            var pipe = Pipe.New<ConnectionContext>(
                    x => x.RabbitMqConsumer(receivePipe, _settings, _receiveObservers, _endpointObservers, _exchangeBindings, supervisor));

            Receiver(pipe, supervisor);

            return new Handle(supervisor);
        }
        /// <summary>
        /// Start the receive transport, returning a Task that can be awaited to signal the transport has 
        /// completely shutdown once the cancellation token is cancelled.
        /// </summary>
        /// <param name="receivePipe"></param>
        /// <returns>A task that is completed once the transport is shut down</returns>
        public ReceiveTransportHandle Start(IPipe<ReceiveContext> receivePipe)
        {
            var supervisor = new TaskSupervisor();

            IPipe<ConnectionContext> pipe = Pipe.New<ConnectionContext>(x =>
            {
                x.RabbitMqConsumer(receivePipe, _settings, _receiveObservable, _receiveEndpointObservable, _bindings, supervisor, _mediator);
            });

            Receiver(pipe, supervisor);

            return new Handle(supervisor);
        }
        /// <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);
        }
Esempio n. 24
0
        public SessionReceiver(ClientContext clientContext, IPipe<ReceiveContext> receivePipe, ClientSettings clientSettings, ITaskSupervisor supervisor, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider)
        {
            _clientContext = clientContext;
            _receivePipe = receivePipe;
            _clientSettings = clientSettings;
            _supervisor = supervisor;
            _sendEndpointProvider = sendEndpointProvider;
            _publishEndpointProvider = publishEndpointProvider;

            _tracker = new DeliveryTracker(HandleDeliveryComplete);

            _participant = supervisor.CreateParticipant($"{TypeMetadataCache<Receiver>.ShortName} - {clientContext.InputAddress}", Stop);
        }
        /// <summary>
        /// Start the receive transport, returning a Task that can be awaited to signal the transport has 
        /// completely shutdown once the cancellation token is cancelled.
        /// </summary>
        /// <param name="receivePipe"></param>
        /// <returns>A task that is completed once the transport is shut down</returns>
        public ReceiveTransportHandle Start(IPipe<ReceiveContext> receivePipe)
        {
            var supervisor = new TaskSupervisor($"{TypeMetadataCache<RabbitMqReceiveTransport>.ShortName} - {_host.Settings.GetInputAddress(_settings)}");

            IPipe<ConnectionContext> pipe = Pipe.New<ConnectionContext>(x =>
            {
                x.RabbitMqConsumer(receivePipe, _settings, _receiveObservable, _receiveEndpointObservable, _bindings, supervisor, _managementPipe);
            });

            Receiver(pipe, supervisor);

            return new Handle(supervisor);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MonitoringChannel" /> class.
        /// </summary>
        /// <param name="keyBuilder">Builds up the final metric key.</param>
        /// <param name="formatter">The message formatter.</param>
        /// <param name="pipe">The pipe.</param>
        public MonitoringChannel(Func<string, string> keyBuilder, IMessageFormatter formatter, IPipe pipe)
        {
            if (pipe == null)
                throw new ArgumentNullException("pipe");

            if (formatter == null)
                throw new ArgumentNullException("formatter");

            this.pipe = pipe;
            this.formatter = formatter;

            this.keyBuilder = keyBuilder ?? (Func<string, string>)((string k) => k);
        }
        public ReceiveTransportHandle Start(IPipe<ReceiveContext> receivePipe)
        {
            var supervisor = new TaskSupervisor($"{TypeMetadataCache<HttpReceiveTransport>.ShortName} - {_host.Settings.GetInputAddress()}");

            IPipe<OwinHostContext> hostPipe = Pipe.New<OwinHostContext>(cxt =>
            {
                cxt.HttpConsumer(receivePipe, _host.Settings, _receiveSettings, _receiveObservable, _receiveTransportObservable, supervisor, _sendPipe);
            });

            var hostTask = _host.OwinHostCache.Send(hostPipe, supervisor.StoppingToken);

            return new Handle(supervisor, hostTask);
        }
        public void CopyToArrayCopiesSelectedPipesToArray()
        {
            Guid[] ids = InitializeTestEntries(3);
            Guid id2 = ids[2];
            IPipe el2 = _pipes[id2];

            _pipes[id2].SetIsSelected(true, SelectionSource.Code, SelectionOrigin.None);

            IPipe[] arr = new IPipe[1];

            _selected.CopyTo(arr, 0);
            Assert.NotNull(arr[0]);
            Assert.Same(el2, arr[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,
            ITaskSupervisor taskSupervisor)
        {
            _model = model;
            _inputAddress = inputAddress;
            _receivePipe = receivePipe;
            _receiveObserver = receiveObserver;

            _receiveSettings = model.GetPayload<ReceiveSettings>();

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

            _participant = taskSupervisor.CreateParticipant();
        }
 public PipeTransitioningGameState(ICamera camera, IPipe warpPipe, Game1 game)
 {
     this.game = game;
     prevGameState = game.gameState;
     this.warpPipe = warpPipe;
     this.camera = camera;
     WorldManager.ReturnPlayer().Physics.ResetX();
     WorldManager.ReturnPlayer().Physics.ResetY();
     controllerList = new List<IController>();
     timer = IGameStateConstants.PIPETRANSITIONINGGAMESTATETIMER;
     controllerList.Add(new KeyboardController(new PausedControls(game)));
     controllerList.Add(new GamePadController(new PausedControls(game)));
     
     
 }
 public Task Publish <T>(object values, IPipe <PublishContext> publishPipe, CancellationToken cancellationToken = default(CancellationToken)) where T : class
 {
     throw new NotImplementedException();
 }
 public ConnectHandle ConnectConsumePipe <T>(IPipe <ConsumeContext <T> > pipe) where T : class
 {
     throw new NotImplementedException();
 }
Esempio n. 33
0
 protected override void SendTelemetryCore(IPipe <TelemetryMessage> pipe)
 {
     SendTelemetryComponent(pipe, Args.Trainer);
     base.SendTelemetryCore(pipe);
 }
Esempio n. 34
0
 public ConnectHandle ConnectConsumePipe <T>(IPipe <ConsumeContext <T> > pipe)
     where T : class
 {
     return(_bus.ConnectConsumePipe(pipe));
 }
Esempio n. 35
0
 public ConnectHandle ConnectRequestPipe <T>(Guid requestId, IPipe <ConsumeContext <T> > pipe)
     where T : class
 {
     return(_bus.ConnectRequestPipe(requestId, pipe));
 }
Esempio n. 36
0
 public Task Publish <T>(T message, IPipe <PublishContext <T> > publishPipe, CancellationToken cancellationToken = default)
     where T : class
 {
     Add(() => _publishEndpoint.Publish(message, publishPipe, cancellationToken));
     return(Task.CompletedTask);
 }
 public TopicSendEndpointContextFactory(IConnectionContextSupervisor supervisor, IPipe <SendEndpointContext> pipe, SendSettings settings)
     : base(supervisor, pipe)
 {
     _settings = settings;
 }
 public static Task Publish(IPublishEndpoint endpoint, object message, Type messageType, IPipe <PublishContext> pipe,
                            CancellationToken cancellationToken = default(CancellationToken))
 {
     return(Cached.Converters.Value[messageType].Publish(endpoint, message, pipe, cancellationToken));
 }
 public static Task Send <TInstance, TData>(this BehaviorContext <TInstance, TData> context, object message, IPipe <SendContext> sendPipe)
 {
     return(GetConsumeContext(context).Send(message, sendPipe));
 }
 public static Task Send <TInstance, TData, T>(this BehaviorContext <TInstance, TData> context, T message, IPipe <SendContext> sendPipe)
     where T : class
 {
     return(GetConsumeContext(context).Send(message, sendPipe));
 }
Esempio n. 41
0
        async Task ISendTransport.Send <T>(T message, IPipe <SendContext <T> > pipe, CancellationToken cancellationToken)
        {
            if (IsStopped)
            {
                throw new TransportUnavailableException($"The send transport is stopped: {_entityName}");
            }

            IPipe <ClientContext> modelPipe = Pipe.New <ClientContext>(p =>
            {
                p.UseFilter(_filter);

                p.UseExecuteAsync(async clientContext =>
                {
                    var sendContext = new TransportAmazonSqsSendContext <T>(message, cancellationToken);
                    try
                    {
                        await pipe.Send(sendContext).ConfigureAwait(false);

                        var transportMessage = clientContext.CreateSendRequest(_entityName, sendContext.Body);

                        transportMessage.MessageAttributes.Set(sendContext.Headers);

                        if (!string.IsNullOrEmpty(sendContext.DeduplicationId))
                        {
                            transportMessage.MessageDeduplicationId = sendContext.DeduplicationId;
                        }

                        if (!string.IsNullOrEmpty(sendContext.GroupId))
                        {
                            transportMessage.MessageGroupId = sendContext.GroupId;
                        }

                        if (sendContext.DelaySeconds.HasValue)
                        {
                            transportMessage.DelaySeconds = sendContext.DelaySeconds.Value;
                        }

                        transportMessage.MessageAttributes.Set("Content-Type", sendContext.ContentType.MediaType);
                        transportMessage.MessageAttributes.Set(nameof(sendContext.MessageId), sendContext.MessageId);
                        transportMessage.MessageAttributes.Set(nameof(sendContext.CorrelationId), sendContext.CorrelationId);
                        transportMessage.MessageAttributes.Set(nameof(sendContext.TimeToLive), sendContext.TimeToLive);

                        await _observers.PreSend(sendContext).ConfigureAwait(false);

                        await clientContext.SendMessage(transportMessage, sendContext.CancellationToken).ConfigureAwait(false);

                        sendContext.LogSent();

                        await _observers.PostSend(sendContext).ConfigureAwait(false);
                    }
                    catch (Exception ex)
                    {
                        sendContext.LogFaulted(ex);

                        await _observers.SendFault(sendContext, ex).ConfigureAwait(false);

                        throw;
                    }
                });
            });

            await _clientSource.Send(modelPipe, cancellationToken).ConfigureAwait(false);
        }
Esempio n. 42
0
        public MessageSendFilter(IEnumerable <IFilter <SendContext <TMessage> > > filters)
        {
            _outputPipe = BuildFilterPipe(filters.ToArray());

            _messageObservers = new SendMessageObservable <TMessage>();
        }
Esempio n. 43
0
        ConnectHandle ConnectStartJobConsumer(IConsumePipeConnector consumePipe, IConsumerSpecification <StartJobConsumer <TJob> > specification,
                                              JobOptions <TJob> options, IJobService jobService, IPipe <ConsumeContext <TJob> > pipe)
        {
            var consumerFactory = new DelegateConsumerFactory <StartJobConsumer <TJob> >(() => new StartJobConsumer <TJob>(jobService, options, pipe));

            return(_startJobConsumerConnector.ConnectConsumer(consumePipe, consumerFactory, specification));
        }
Esempio n. 44
0
 public Task Publish <T>(object values, IPipe <PublishContext> publishPipe, CancellationToken cancellationToken = default)
     where T : class
 {
     Add(() => _publishEndpoint.Publish <T>(values, publishPipe, cancellationToken));
     return(Task.CompletedTask);
 }
Esempio n. 45
0
        public async Task <ScheduledMessage <T> > ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, Task <T> message, IPipe <SendContext <T> > pipe,
                                                                   CancellationToken cancellationToken)
            where T : class
        {
            var messageId = NewId.NextGuid();

            IPipe <SendContext <T> > delayPipe = Pipe.ExecuteAsync <SendContext <T> >(async context =>
            {
                context.MessageId     = messageId;
                var rabbitSendContext = context.GetPayload <RabbitMqSendContext>();

                var delay = Math.Max(0, (scheduledTime.Kind == DateTimeKind.Local
                    ? scheduledTime - DateTime.Now
                    : scheduledTime - DateTime.UtcNow).TotalMilliseconds);

                if (delay > 0)
                {
                    rabbitSendContext.SetTransportHeader("x-delay", (long)delay);
                }

                await pipe.Send(context).ConfigureAwait(false);
            });

            var payload = await message.ConfigureAwait(false);

            var schedulerEndpoint = await GetSchedulerEndpoint(destinationAddress).ConfigureAwait(false);

            await schedulerEndpoint.Send(payload, delayPipe, cancellationToken).ConfigureAwait(false);

            return(new ScheduledMessageHandle <T>(messageId, scheduledTime, destinationAddress, payload));
        }
Esempio n. 46
0
 public RequestConfigurator(IPipe <RequestContext> pipe)
 {
     _pipe = pipe;
 }
Esempio n. 47
0
 public Task Publish(object message, Type messageType, IPipe <PublishContext> publishPipe, CancellationToken cancellationToken = default)
 {
     Add(() => _publishEndpoint.Publish(message, messageType, publishPipe, cancellationToken));
     return(Task.CompletedTask);
 }
Esempio n. 48
0
 public Task Publish <T>(T message, IPipe <PublishContext> publishPipe, CancellationToken cancellationToken)
     where T : class
 {
     return(PublishInternal(cancellationToken, message, publishPipe));
 }
Esempio n. 49
0
 Task IPublishEndpoint.Publish(object message, IPipe <PublishContext> publishPipe, CancellationToken cancellationToken)
 {
     return(_context.Publish(message, publishPipe, cancellationToken));
 }
Esempio n. 50
0
        Task <ScheduledMessage <T> > IMessageScheduler.ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, T message, IPipe <SendContext> pipe,
                                                                        CancellationToken cancellationToken)
        {
            if (destinationAddress == null)
            {
                throw new ArgumentNullException(nameof(destinationAddress));
            }
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            if (pipe == null)
            {
                throw new ArgumentNullException(nameof(pipe));
            }

            var pipeProxy = new ScheduleMessageContextPipe <T>(pipe);

            return(ScheduleSend(destinationAddress, scheduledTime, message, pipeProxy, cancellationToken));
        }
Esempio n. 51
0
 public ConnectHandle ConnectConsumePipe <T>(IPipe <ConsumeContext <T> > pipe, ConnectPipeOptions options)
     where T : class
 {
     return(_bus.ConnectConsumePipe(pipe, options));
 }
Esempio n. 52
0
 Task IPublishEndpoint.Publish <T>(object values, IPipe <PublishContext> publishPipe,
                                   CancellationToken cancellationToken)
 {
     return(_context.Publish <T>(values, publishPipe, cancellationToken));
 }
 public Task Publish(object message, Type messageType, IPipe <PublishContext> publishPipe, CancellationToken cancellationToken = default(CancellationToken))
 {
     throw new NotImplementedException();
 }
 public ServiceBusScheduleSendPipe(IPipe <SendContext <T> > pipe, DateTime scheduledTime)
     : base(pipe)
 {
     _scheduledTime = scheduledTime;
 }
Esempio n. 55
0
 public Task Publish(object message, Type messageType, IPipe <PublishContext> publishPipe, CancellationToken cancellationToken)
 {
     return(PublishEndpointConverterCache.Publish(this, message, messageType, publishPipe, cancellationToken));
 }
 public Task Publish <T>(T message, IPipe <PublishContext> publishPipe, CancellationToken cancellationToken = default(CancellationToken)) where T : class
 {
     return(Task.CompletedTask);
 }
Esempio n. 57
0
 public PipeAdapter(IPipe <PublishContext <T> > pipe)
 {
     _pipe = pipe;
 }
 public ConnectHandle ConnectRequestPipe <T>(Guid requestId, IPipe <ConsumeContext <T> > pipe) where T : class
 {
     throw new NotImplementedException();
 }
Esempio n. 59
0
        public async Task Send(T message, IPipe <SendContext <T> > pipe, CancellationToken cancellationToken)
        {
            var sendEndpoint = await _context.GetSendEndpoint(_destinationAddress).ConfigureAwait(false);

            await sendEndpoint.Send(message, pipe, cancellationToken).ConfigureAwait(false);
        }
Esempio n. 60
0
 public ScheduleMessageContextPipe(IPipe <SendContext <T> > pipe)
 {
     _pipe = pipe;
 }