public ServiceBusSendTransport(MessageSender sender, ITaskSupervisor supervisor) { _observers = new SendObservable(); _sender = sender; _participant = supervisor.CreateParticipant($"{TypeMetadataCache<ServiceBusSendTransport>.ShortName} - {sender.Path}", StopSender); }
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 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 ServiceBusSendTransport(ISendClient client, ITaskSupervisor supervisor) { _client = client; _observers = new SendObservable(); _participant = supervisor.CreateParticipant($"{TypeMetadataCache<ServiceBusSendTransport>.ShortName} - {client.Path}", StopSender); }
public SharedHttpOwinHostContext(OwinHostContext context, CancellationToken cancellationToken, ITaskSupervisor scope) { _context = context; CancellationToken = cancellationToken; _participant = scope.CreateParticipant($"{TypeMetadataCache<SharedHttpOwinHostContext>.ShortName} - {context.HostSettings.ToDebugString()}"); _participant.SetReady(); }
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 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> /// 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, ITaskSupervisor taskSupervisor) { _model = model; _inputAddress = inputAddress; _receivePipe = receivePipe; _receiveObserver = receiveObserver; _receiveSettings = model.GetPayload <ReceiveSettings>(); _pending = new ConcurrentDictionary <ulong, RabbitMqReceiveContext>(); _participant = taskSupervisor.CreateParticipant(); }
public Receiver(NamespaceContext context, ClientContext clientContext, IPipe <ReceiveContext> receivePipe, ClientSettings clientSettings, ITaskSupervisor supervisor, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider) { _context = context; _clientContext = clientContext; _receivePipe = receivePipe; _clientSettings = clientSettings; _sendEndpointProvider = sendEndpointProvider; _publishEndpointProvider = publishEndpointProvider; _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(); }
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; _participant = supervisor.CreateParticipant($"{TypeMetadataCache<Receiver>.ShortName} - {inputAddress}", Stop); 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(); }
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(); }
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 Receiver(NamespaceContext context, ClientContext clientContext, IPipe<ReceiveContext> receivePipe, ClientSettings clientSettings, ITaskSupervisor supervisor, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider) { _context = context; _clientContext = clientContext; _receivePipe = receivePipe; _clientSettings = clientSettings; _sendEndpointProvider = sendEndpointProvider; _publishEndpointProvider = publishEndpointProvider; _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(); }
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(); }
public static ITaskParticipant CreateParticipant(this ITaskSupervisor supervisor, string tag, Func <Task> onStopMethod) { var participant = supervisor.CreateParticipant(tag); participant.StopRequested.ContinueWith(async stopTask => { try { await onStopMethod().ConfigureAwait(false); } catch (Exception ex) { _log.Error($"Failed to close scope {tag}", ex); } finally { participant.SetComplete(); } }, TaskScheduler.Default); return(participant); }
public RabbitMqConnectionContext(IConnection connection, RabbitMqHostSettings hostSettings, ITaskSupervisor supervisor) : this(connection, hostSettings, supervisor.CreateParticipant($"{TypeMetadataCache<RabbitMqConnectionContext>.ShortName} - {hostSettings.ToDebugString()}")) { }
public RabbitMqConnectionContext(IConnection connection, RabbitMqHostSettings hostSettings, IRabbitMqHostTopology topology, string description, ITaskSupervisor supervisor) : this(connection, hostSettings, description, supervisor.CreateParticipant($"{TypeMetadataCache<RabbitMqConnectionContext>.ShortName} - {description}")) { Topology = topology; }
public HttpOwinHostContext(HttpHostSettings settings, ITaskSupervisor supervisor) : this(settings, supervisor.CreateParticipant($"{TypeMetadataCache<HttpOwinHostContext>.ShortName} - {settings.ToDebugString()}")) { }
public RabbitMqConnectionContext(IConnection connection, RabbitMqHostSettings hostSettings, ITaskSupervisor supervisor) : this(connection, hostSettings, supervisor.CreateParticipant($"{TypeMetadataCache<RabbitMqConnectionContext>.ShortName} - {hostSettings.ToDebugString()}")) { }
public HttpOwinHostContext(HttpHostSettings settings, ITaskSupervisor supervisor) : this(settings, supervisor.CreateParticipant($"{TypeMetadataCache<HttpOwinHostContext>.ShortName} - {settings.ToDebugString()}")) { }