public TopicPartitionQueue(IMessageHandler <TKey, TValue> messageHandler, int queueCapacity) { _messageHandler = messageHandler; _bufferBlock = new BufferBlock <Message <TKey, TValue> >( new DataflowBlockOptions { BoundedCapacity = queueCapacity }); _actionBlock = new ActionBlock <Message <TKey, TValue> >( _messageHandler.HandleAsync, new ExecutionDataflowBlockOptions { BoundedCapacity = 1 }); _bufferBlock.LinkTo(_actionBlock, new DataflowLinkOptions { PropagateCompletion = true }); _actionBlock.PropagateErrorsTo(_bufferBlock); }