public SenderChannel( IChannelInformation channelInformation, ITransport transport, ICollection <IChannelModule <Message> > messageModules, ICollection <IChannelModule <Notification> > notificationModules, ICollection <IChannelModule <Command> > commandModules, Func <Exception, Task> exceptionHandler, int envelopeBufferSize, TimeSpan sendTimeout) { if (sendTimeout == default) { throw new ArgumentException("Invalid send timeout", nameof(sendTimeout)); } _channelInformation = channelInformation; _transport = transport; _messageModules = messageModules; _notificationModules = notificationModules; _commandModules = commandModules; _exceptionHandler = exceptionHandler; _sendTimeout = sendTimeout; _sessionSemaphore = new SemaphoreSlim(1); _startStopSemaphore = new SemaphoreSlim(1); _senderCts = new CancellationTokenSource(); _envelopeBuffer = ChannelUtil.CreateForCapacity <Envelope>(envelopeBufferSize, true, false); }
public ReceiverChannel( IChannelInformation channelInformation, ITransport transport, IChannelCommandProcessor channelCommandProcessor, ICollection <IChannelModule <Message> > messageModules, ICollection <IChannelModule <Notification> > notificationModules, ICollection <IChannelModule <Command> > commandModules, Func <Exception, Task> exceptionHandler, int envelopeBufferSize, TimeSpan?consumeTimeout) { if (consumeTimeout != null && consumeTimeout.Value == default) { throw new ArgumentException("Invalid consume timeout", nameof(consumeTimeout)); } _channelInformation = channelInformation; _transport = transport; _channelCommandProcessor = channelCommandProcessor; _messageModules = messageModules; _notificationModules = notificationModules; _commandModules = commandModules; _exceptionHandler = exceptionHandler; _consumeTimeout = consumeTimeout; _sessionSemaphore = new SemaphoreSlim(1); _startStopSemaphore = new SemaphoreSlim(1); _consumerCts = new CancellationTokenSource(); _messageBuffer = ChannelUtil.CreateForCapacity <Message>(envelopeBufferSize, false, true); _notificationBuffer = ChannelUtil.CreateForCapacity <Notification>(envelopeBufferSize, false, true); _commandBuffer = ChannelUtil.CreateForCapacity <Command>(envelopeBufferSize, false, true); _sessionBuffer = ChannelUtil.CreateForCapacity <Session>(envelopeBufferSize, false, true); }
private static IChannelListener CreateChannelListener(IChannelInformation channelInformation) { var serverChannel = (IServerChannel)channelInformation; return(new ChannelListener( (m, ct) => ConsumeMessageAsync(m, serverChannel, ct), (n, ct) => ConsumeNotificationAsync(n, serverChannel, ct), (c, ct) => ConsumeCommandAsync(c, serverChannel, ct))); }
public Task HandleDeadMessageAsync(Message message, IChannelInformation channelInformation, CancellationToken cancellationToken) => TaskUtil.CompletedTask;