public Consumer( Guid correlationId, Uri serviceUrl, string subscriptionName, string topic, IRegisterEvent eventRegister, IConsumerChannel <TMessage> initialChannel, IExecute executor, IStateChanged <ConsumerState> state, IConsumerChannelFactory <TMessage> factory) { _correlationId = correlationId; ServiceUrl = serviceUrl; SubscriptionName = subscriptionName; Topic = topic; _eventRegister = eventRegister; _channel = initialChannel; _executor = executor; _state = state; _factory = factory; _commandAckPool = new DefaultObjectPool <CommandAck>(new DefaultPooledObjectPolicy <CommandAck>()); _isDisposed = 0; _eventRegister.Register(new ConsumerCreated(_correlationId)); }
public async Task EstablishNewChannel(CancellationToken cancellationToken) { var channel = await _executor.Execute(() => _factory.Create(cancellationToken), cancellationToken).ConfigureAwait(false); var oldChannel = _channel; _channel = channel; if (oldChannel is not null) { await oldChannel.DisposeAsync().ConfigureAwait(false); } }
public Consumer( Guid correlationId, IRegisterEvent eventRegister, IConsumerChannel initialChannel, IExecute executor, IStateChanged <ConsumerState> state) { _correlationId = correlationId; _eventRegister = eventRegister; _channel = initialChannel; _executor = executor; _state = state; _cachedCommandAck = new CommandAck(); _isDisposed = 0; _eventRegister.Register(new ConsumerCreated(_correlationId, this)); }
internal async ValueTask SetChannel(IConsumerChannel channel) { if (_isDisposed != 0) { await channel.DisposeAsync().ConfigureAwait(false); return; } var oldChannel = _channel; _channel = channel; if (oldChannel is not null) { await oldChannel.DisposeAsync().ConfigureAwait(false); } }
public Consumer( Guid correlationId, string topic, IRegisterEvent eventRegister, IConsumerChannel initialChannel, IExecute executor, IStateChanged <ConsumerState> state) { _correlationId = correlationId; Topic = topic; _eventRegister = eventRegister; _channel = initialChannel; _executor = executor; _state = state; _commandAckPool = new DefaultObjectPool <CommandAck>(new DefaultPooledObjectPolicy <CommandAck>()); _isDisposed = 0; _eventRegister.Register(new ConsumerCreated(_correlationId, this)); }
public Reader( Guid correlationId, Uri serviceUrl, string topic, IRegisterEvent eventRegister, IConsumerChannel initialChannel, IExecute executor, IStateChanged <ReaderState> state) { _correlationId = correlationId; ServiceUrl = serviceUrl; Topic = topic; _eventRegister = eventRegister; _channel = initialChannel; _executor = executor; _state = state; _isDisposed = 0; _eventRegister.Register(new ReaderCreated(_correlationId, this)); }
internal void SetChannel(IConsumerChannel channel) { ThrowIfDisposed(); _channel = channel; }