protected virtual void AddConsumerToQueue(IConsumer consumer)
{
var queue = consumer.GetQueueDetails();
if (queue == null || string.IsNullOrEmpty(queue.Name))
{
throw new Exception("Invalid queue details");
}
if (!CanPerformChannelOperations)
{
throw new InvalidOperationException("Cannot accept new consumers at the moment");
}
var model = _streamConnection.CreateModel();
StreamSubscriber subscriber = null;
try
{
subscriber = new StreamSubscriber(model, consumer, Dispatcher);
subscriber.StartConsuming(queue.Name);
}
catch
{
if (subscriber != null)
{
subscriber.Dispose();
}
throw;
}
}