public GlobalIncomingUpdateQueue() { var channelHolder = new ChannelHolder <Update>(); _channelReaderProvider = channelHolder; _channelWriterProvider = channelHolder; }
public ChannelHolder GetChannelHolder() { lock (_consumersMonitor) { ChannelHolder channelHolder = null; while (channelHolder == null) { if (!IsRunning) { throw new InvalidOperationException("Direct reply-to container is not running"); } foreach (var consumer in _consumers) { var candidate = consumer.Model; if (candidate.IsOpen && _inUseConsumerChannels.TryAdd(candidate, consumer)) { channelHolder = new ChannelHolder(candidate, consumer.IncrementAndGetEpoch()); _whenUsed[consumer] = DateTimeOffset.Now.ToUnixTimeMilliseconds(); break; } } if (channelHolder == null) { _consumerCount++; base.ConsumersPerQueue = _consumerCount; } } return(channelHolder); } }
public GlobalOutgoingRequestQueue() { var channelHolder = new ChannelHolder <Request>(); _channelReaderProvider = channelHolder; _channelWriterProvider = channelHolder; }
public void ReleaseConsumerFor(ChannelHolder channelHolder, bool cancelConsumer, string message) { lock (_consumersMonitor) { _inUseConsumerChannels.TryGetValue(channelHolder.Channel, out var consumer); if (consumer != null && consumer.Epoch == channelHolder.ConsumerEpoch) { _inUseConsumerChannels.Remove(channelHolder.Channel, out _); if (cancelConsumer) { if (message == null) { throw new ArgumentNullException("A 'message' is required when 'cancelConsumer' is 'true'"); } consumer.CancelConsumer("Consumer " + this + " canceled due to " + message); } } } }
public WcfInvocation Refresh() { ChannelHolder.RefreshChannel(); return(this); }