async Task IFilter <ModelContext> .Send(ModelContext context, IPipe <ModelContext> next) { var receiveSettings = context.GetPayload <ReceiveSettings>(); var inputAddress = context.ConnectionContext.HostSettings.GetInputAddress(receiveSettings); using (ITaskScope scope = _supervisor.CreateScope($"{TypeMetadataCache<RabbitMqConsumerFilter>.ShortName} - {inputAddress}", () => TaskUtil.Completed)) { var consumer = new RabbitMqBasicConsumer(context, inputAddress, _receivePipe, _receiveObserver, scope); await context.BasicConsume(receiveSettings.QueueName, false, consumer).ConfigureAwait(false); await scope.Ready.ConfigureAwait(false); await _endpointObserver.Ready(new Ready(inputAddress)).ConfigureAwait(false); scope.SetReady(); try { await scope.Completed.ConfigureAwait(false); } finally { RabbitMqConsumerMetrics metrics = consumer; await _endpointObserver.Completed(new Completed(inputAddress, metrics)).ConfigureAwait(false); if (_log.IsDebugEnabled) { _log.DebugFormat("Consumer {0}: {1} received, {2} concurrent", metrics.ConsumerTag, metrics.DeliveryCount, metrics.ConcurrentDeliveryCount); } } } }
public RabbitMqModelCache(IConnectionCache connectionCache, ITaskSupervisor supervisor, ModelSettings modelSettings) { _connectionCache = connectionCache; _modelSettings = modelSettings; _cacheTaskScope = supervisor.CreateScope($"{TypeMetadataCache<RabbitMqModelCache>.ShortName}", CloseScope); }
public RabbitMqConnectionCache(RabbitMqHostSettings settings, ITaskSupervisor supervisor) { _settings = settings; _connectionFactory = settings.GetConnectionFactory(); _cacheTaskScope = supervisor.CreateScope($"{TypeMetadataCache<RabbitMqConnectionCache>.ShortName} - {settings.ToDebugString()}", CloseScope); }
public RabbitMqConnectionCache(RabbitMqHostSettings settings, IRabbitMqHostTopology topology, ITaskSupervisor supervisor) { _settings = settings; _topology = topology; _connectionFactory = new Lazy <ConnectionFactory>(settings.GetConnectionFactory); _description = settings.ToDebugString(); _cacheTaskScope = supervisor.CreateScope($"{TypeMetadataCache<RabbitMqConnectionCache>.ShortName} - {_description}", CloseScope); }
/// <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>(); }
/// <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>(); }
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(); }
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(); }
public ModelScope(ITaskScope supervisor) { _modelContext = new TaskCompletionSource<RabbitMqModelContext>(); _taskScope = supervisor.CreateScope("ModelScope", CloseContext); }
public HttpClientCache(ITaskSupervisor supervisor, IReceivePipe receivePipe) { _receivePipe = receivePipe; _cacheTaskScope = supervisor.CreateScope($"{TypeMetadataCache<HttpClientCache>.ShortName}", CloseScope); }
public ClientScope(ITaskScope supervisor) { _clientContext = new TaskCompletionSource<HttpClientContext>(); _taskScope = supervisor.CreateScope("ClientScope", CloseContext); }
public RabbitMqModelCache(IRabbitMqHost host) { _host = host; _cacheTaskScope = host.Supervisor.CreateScope($"{TypeMetadataCache<RabbitMqModelCache>.ShortName}", CloseScope); }
public ConnectionScope(ITaskScope scope, string debugString) { _connectionContext = new TaskCompletionSource <RabbitMqConnectionContext>(); _taskScope = scope.CreateScope($"ConnectionScope: {debugString}", CloseContext); }
public HttpClientContext(HttpClient client, IReceivePipe receivePipe, ITaskScope taskScope) : this(client, receivePipe, taskScope.CreateParticipant($"{TypeMetadataCache<HttpClientContext>.ShortName} - {client.BaseAddress}")) { }
public SharedModelContext(ModelContext context, CancellationToken cancellationToken, ITaskScope scope) { _context = context; _cancellationToken = cancellationToken; _participant = scope.CreateParticipant($"{TypeMetadataCache<SharedModelContext>.ShortName} - {context.ConnectionContext.HostSettings.ToDebugString()}"); _participant.SetReady(); }
public SharedConnectionContext(ConnectionContext context, CancellationToken cancellationToken, ITaskScope scope) { _context = context; _cancellationToken = cancellationToken; _participant = scope.CreateParticipant($"{TypeMetadataCache<SharedConnectionContext>.ShortName} - {context.Description}"); _participant.SetReady(); }
public ClientScope(ITaskScope supervisor) { _clientContext = new TaskCompletionSource <HttpClientContext>(); _taskScope = supervisor.CreateScope("ClientScope", CloseContext); }
public OwinHostCache(HttpHostSettings settings, ITaskSupervisor supervisor) { _settings = settings; _cacheTaskScope = supervisor.CreateScope($"{TypeMetadataCache<OwinHostCache>.ShortName} - {settings.ToDebugString()}", CloseScope); }
public OwinHostScope(ITaskScope scope, HttpHostSettings settings) { _owinHostContext = new TaskCompletionSource<HttpOwinHostContext>(); _taskScope = scope.CreateScope($"{TypeMetadataCache<OwinHostScope>.ShortName} - {settings.ToDebugString()}", CloseContext); }
public ModelScope(ITaskScope supervisor) { _modelContext = new TaskCompletionSource <RabbitMqModelContext>(); _taskScope = supervisor.CreateScope("ModelScope", CloseContext); }
public ConnectionScope(ITaskScope scope, RabbitMqHostSettings settings) { _connectionContext = new TaskCompletionSource <RabbitMqConnectionContext>(); _taskScope = scope.CreateScope($"ConnectionScope: {settings.ToDebugString()}", CloseContext); }
public RabbitMqModelContext(ConnectionContext connectionContext, IModel model, ITaskScope taskScope, ModelSettings settings) : this(connectionContext, model, settings, taskScope.CreateParticipant($"{TypeMetadataCache<RabbitMqModelContext>.ShortName} - {connectionContext.HostSettings.ToDebugString()}")) { }
public RabbitMqModelContext(ConnectionContext connectionContext, IModel model, ITaskScope taskScope, IRabbitMqHost host) : this(connectionContext, model, host, taskScope.CreateParticipant($"{TypeMetadataCache<RabbitMqModelContext>.ShortName} - {connectionContext.HostSettings.ToDebugString()}")) { }
public SharedHttpClientContext(ClientContext context, CancellationToken cancellationToken, ITaskScope scope) { _context = context; _cancellationToken = cancellationToken; _participant = scope.CreateParticipant($"{TypeMetadataCache<SharedHttpClientContext>.ShortName} - {context.BaseAddress}"); _participant.SetReady(); }
public OwinHostScope(ITaskScope scope, HttpHostSettings settings) { _owinHostContext = new TaskCompletionSource <HttpOwinHostContext>(); _taskScope = scope.CreateScope($"{TypeMetadataCache<OwinHostScope>.ShortName} - {settings.ToDebugString()}", CloseContext); }
public ConnectionScope(ITaskScope scope, RabbitMqHostSettings settings) { _connectionContext = new TaskCompletionSource<RabbitMqConnectionContext>(); _taskScope = scope.CreateScope($"ConnectionScope: {settings.ToDebugString()}", CloseContext); }