public CommunicateChannel(IMessageConnection connection, PublisherContext publisherContext) { _connection = connection; _publisherContext = publisherContext; PublisherBind(publisherContext); }
private ICommunicateChannel CreateChannel(PublisherContext publisherContext) { if(!_channelPools.Any() || _channelPools.Last().IsFull()) _channelPools.Add(new CommunicateChannelFactory(_endpoint)); var channel = _channelPools.Last().GetChannel(publisherContext); return channel; }
public ICommunicateChannel GetChannel(PublisherContext publisherContext) { CheckConnection(); if (!_channelPools.ContainsKey(publisherContext.ExchangeName)) { var channel = new CommunicateChannel(_connection, publisherContext); _channelPools.TryAdd(publisherContext.ExchangeName, channel); } return _channelPools[publisherContext.ExchangeName]; }
public ICommunicateChannel GetChannel(PublisherContext publisherContext) { var communicateChannel = default(ICommunicateChannel); for (var i = 0; i < _channelPools.Count; i++) { if (_channelPools[i].ContainsChannel(publisherContext)) { communicateChannel = _channelPools[i].GetChannel(publisherContext); break; } } if (communicateChannel != null) return communicateChannel; return CreateChannel(publisherContext); }
private void PublisherBind(PublisherContext publisherContext) { _channel = _connection.CreateChannel(); _channel.ExchangeDeclare(publisherContext.ExchangeName, publisherContext.ExchangeType, true); }
public bool ContainsChannel(PublisherContext publisherContext) { return _channelPools.ContainsKey(publisherContext.ExchangeName); }