Пример #1
0
        public async Task <BaseCommand> Send(SendPackage command, CancellationToken cancellationToken)
        {
            ThrowIfDisposed();

            if (command.Command is null)
            {
                throw new ArgumentNullException(nameof(command.Command));
            }

            if (command.Metadata is null)
            {
                throw new ArgumentNullException(nameof(command.Metadata));
            }

            Task <BaseCommand>?response;

            using (await _lock.Lock(cancellationToken).ConfigureAwait(false))
            {
                var baseCommand = command.Command.AsBaseCommand();
                response = _requestResponseHandler.Outgoing(baseCommand);
                var sequence = Serializer.Serialize(baseCommand, command.Metadata, command.Payload);
                await _stream.Send(sequence).ConfigureAwait(false);
            }

            return(await response.ConfigureAwait(false));
        }
Пример #2
0
        public async Task <BaseCommand> Send(SendPackage command)
        {
            Task <BaseCommand>?response = null;

            using (await _lock.Lock())
            {
                var baseCommand = command.Command.AsBaseCommand();
                response = _requestResponseHandler.Outgoing(baseCommand);
                var sequence = Serializer.Serialize(baseCommand, command.Metadata, command.Payload);
                await _stream.Send(sequence);
            }
            return(await response);
        }
Пример #3
0
        public async Task <BaseCommand> Send(SendPackage command, CancellationToken cancellationToken)
        {
            ThrowIfDisposed();

            Task <BaseCommand>?responseTask;

            using (await _lock.Lock(cancellationToken).ConfigureAwait(false))
            {
                responseTask = _channelManager.Outgoing(command.Command !);
                var sequence = Serializer.Serialize(command.Command !.AsBaseCommand(), command.Metadata !, command.Payload);
                await _stream.Send(sequence).ConfigureAwait(false);
            }

            return(await responseTask.ConfigureAwait(false));
        }
Пример #4
0
        public ProducerChannel(ulong id, string name, SequenceId sequenceId, IConnection connection)
        {
            _cachedMetadata = new MessageMetadata {
                ProducerName = name
            };

            var commandSend = new CommandSend {
                ProducerId = id, NumMessages = 1
            };

            _cachedSendPackage = new SendPackage(commandSend, _cachedMetadata);

            _id         = id;
            _sequenceId = sequenceId;
            _connection = connection;
        }
Пример #5
0
        public async Task <BaseCommand> Send(SendPackage command, CancellationToken cancellationToken)
        {
            ThrowIfDisposed();

            Task <BaseCommand>?response;

            using (await _lock.Lock(cancellationToken).ConfigureAwait(false))
            {
                var baseCommand = command.Command !.AsBaseCommand();
                response = _requestResponseHandler.Outgoing(baseCommand);
                var sequence = Serializer.Serialize(baseCommand, command.Metadata !, command.Payload);
                await _stream.Send(sequence).ConfigureAwait(false);
            }

            return(await response.ConfigureAwait(false));
        }
Пример #6
0
        public ProducerStream(ulong id, string name, SequenceId sequenceId, Connection connection, IFaultStrategy faultStrategy, IProducerProxy proxy)
        {
            _cachedMetadata = new PulsarApi.MessageMetadata
            {
                ProducerName = name
            };

            var commandSend = new CommandSend
            {
                ProducerId  = id,
                NumMessages = 1
            };

            _cachedSendPackage = new SendPackage(commandSend, _cachedMetadata);

            _id            = id;
            _sequenceId    = sequenceId;
            _connection    = connection;
            _faultStrategy = faultStrategy;
            _proxy         = proxy;
        }