예제 #1
0
        public Producer(
            Guid correlationId,
            Uri serviceUrl,
            string topic,
            ulong initialSequenceId,
            IRegisterEvent registerEvent,
            IProducerChannel initialChannel,
            IExecute executor,
            IStateChanged <ProducerState> state,
            IProducerChannelFactory factory,
            ISchema <TMessage> schema)
        {
            var messageMetadataPolicy = new DefaultPooledObjectPolicy <PulsarApi.MessageMetadata>();

            _messageMetadataPool = new DefaultObjectPool <PulsarApi.MessageMetadata>(messageMetadataPolicy);
            _correlationId       = correlationId;
            ServiceUrl           = serviceUrl;
            Topic          = topic;
            _sequenceId    = new SequenceId(initialSequenceId);
            _eventRegister = registerEvent;
            _channel       = initialChannel;
            _executor      = executor;
            _state         = state;
            _factory       = factory;
            _schema        = schema;
            _isDisposed    = 0;

            _eventRegister.Register(new ProducerCreated(_correlationId));
        }
예제 #2
0
        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));
        }
예제 #3
0
        public async ValueTask DisposeAsync()
        {
            if (Interlocked.Exchange(ref _isDisposed, 1) != 0)
            {
                return;
            }

            _eventRegister.Register(new ConsumerDisposed(_correlationId, this));
            await _channel.DisposeAsync();
        }
예제 #4
0
        public async ValueTask DisposeAsync()
        {
            if (Interlocked.Exchange(ref _isDisposed, 1) != 0)
            {
                return;
            }

            _eventRegister.Register(new ProducerDisposed(_correlationId, this));

            await _channel.DisposeAsync().ConfigureAwait(false);
        }
예제 #5
0
        public async ValueTask DisposeAsync()
        {
            if (Interlocked.Exchange(ref _isDisposed, 1) != 0)
            {
                return;
            }

            _eventRegister.Register(new ReaderDisposed(_correlationId));
            await _channel.ClosedByClient(CancellationToken.None).ConfigureAwait(false);

            await _channel.DisposeAsync().ConfigureAwait(false);
        }
예제 #6
0
        public Reader(
            Guid correlationId,
            IRegisterEvent eventRegister,
            IReaderChannel initialChannel,
            IExecute executor,
            IStateChanged <ReaderState> state)
        {
            _correlationId = correlationId;
            _eventRegister = eventRegister;
            _channel       = initialChannel;
            _executor      = executor;
            _state         = state;
            _isDisposed    = 0;

            _eventRegister.Register(new ReaderCreated(_correlationId, this));
        }
예제 #7
0
        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));
        }
예제 #8
0
        public Producer(
            Guid correlationId,
            string topic,
            IRegisterEvent registerEvent,
            IProducerChannel initialChannel,
            IExecute executor,
            IStateChanged <ProducerState> state)
        {
            _correlationId = correlationId;
            Topic          = topic;
            _eventRegister = registerEvent;
            _channel       = initialChannel;
            _executor      = executor;
            _state         = state;
            _isDisposed    = 0;

            _eventRegister.Register(new ProducerCreated(_correlationId, this));
        }
예제 #9
0
        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));
        }
예제 #10
0
        private async ValueTask <bool> Handle(Exception exception, CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return(true);
            }

            var context = new ExceptionContext(exception, cancellationToken);

            await _exceptionHandler.OnException(context).ConfigureAwait(false);

            if (context.Result != FaultAction.Retry)
            {
                _eventRegister.Register(new ExecutorFaulted(_correlationId));
            }

            return(context.Result == FaultAction.ThrowException
                ? throw context.Exception
                : context.Result == FaultAction.Rethrow);
        }
예제 #11
0
        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));
        }
예제 #12
0
        public Producer(
            Guid correlationId,
            string topic,
            ulong initialSequenceId,
            IRegisterEvent registerEvent,
            IProducerChannel initialChannel,
            IExecute executor,
            IStateChanged <ProducerState> state)
        {
            var messageMetadataPolicy = new DefaultPooledObjectPolicy <PulsarApi.MessageMetadata>();

            _messageMetadataPool = new DefaultObjectPool <PulsarApi.MessageMetadata>(messageMetadataPolicy);
            _correlationId       = correlationId;
            Topic          = topic;
            _sequenceId    = new SequenceId(initialSequenceId);
            _eventRegister = registerEvent;
            _channel       = initialChannel;
            _executor      = executor;
            _state         = state;
            _isDisposed    = 0;

            _eventRegister.Register(new ProducerCreated(_correlationId, this));
        }
예제 #13
0
        public SubProducer(
            Guid correlationId,
            Uri serviceUrl,
            string topic,
            IRegisterEvent registerEvent,
            IProducerChannel initialChannel,
            IExecute executor,
            IStateChanged <ProducerState> state,
            IProducerChannelFactory factory,
            ISchema <TMessage> schema)
        {
            _correlationId = correlationId;
            ServiceUrl     = serviceUrl;
            Topic          = topic;
            _eventRegister = registerEvent;
            _channel       = initialChannel;
            _executor      = executor;
            _state         = state;
            _factory       = factory;
            _schema        = schema;
            _isDisposed    = 0;

            _eventRegister.Register(new ProducerCreated(_correlationId));
        }
예제 #14
0
 public void Activated() => _eventRegister.Register(new ChannelActivated(_correlationId));