public IMessageConsumer CreateDurableConsumer(ITopic destination, string name, string selector, bool noLocal)
{
if(destination == null)
{
throw new InvalidDestinationException("Cannot create a Consumer with a Null destination");
}
ActiveMQDestination dest = ActiveMQDestination.Transform(destination);
MessageConsumer consumer = null;
try
{
consumer = new MessageConsumer(this, GetNextConsumerId(), dest, name, selector,
this.connection.PrefetchPolicy.DurableTopicPrefetch,
this.connection.PrefetchPolicy.MaximumPendingMessageLimit,
noLocal, false, this.connection.DispatchAsync);
consumer.ConsumerTransformer = this.ConsumerTransformer;
this.AddConsumer(consumer);
this.Connection.SyncRequest(consumer.ConsumerInfo);
if(this.Connection.IsStarted)
{
consumer.Start();
}
}
catch(Exception)
{
if(consumer != null)
{
this.RemoveConsumer(consumer.ConsumerId);
consumer.Close();
}
throw;
}
return consumer;
}