Apache.NMS.ActiveMQ.Session.CreateDurableConsumer C# (CSharp) Method

CreateDurableConsumer() public method

public CreateDurableConsumer ( ITopic destination, string name, string selector, bool noLocal ) : IMessageConsumer
destination ITopic
name string
selector string
noLocal bool
return IMessageConsumer
        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;
        }