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)); }
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); }
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)); }
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; }
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)); }
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; }