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

CreateConsumer() public method

public CreateConsumer ( IDestination destination, string selector, bool noLocal ) : IMessageConsumer
destination IDestination
selector string
noLocal bool
return IMessageConsumer
        public IMessageConsumer CreateConsumer(IDestination destination, string selector, bool noLocal)
        {
            if(destination == null)
            {
                throw new InvalidDestinationException("Cannot create a Consumer with a Null destination");
            }

            ActiveMQDestination dest = ActiveMQDestination.Transform(destination);
            int prefetchSize = this.Connection.PrefetchPolicy.DurableTopicPrefetch;

            if(dest is ITopic || dest is ITemporaryTopic)
            {
                prefetchSize = this.connection.PrefetchPolicy.TopicPrefetch;
            }
            else if(dest is IQueue || dest is ITemporaryQueue)
            {
                prefetchSize = this.connection.PrefetchPolicy.QueuePrefetch;
            }

            MessageConsumer consumer = null;

            try
            {
                consumer = new MessageConsumer(this, GetNextConsumerId(), dest, null, selector, prefetchSize,
                                               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;
        }

Same methods

Session::CreateConsumer ( IDestination destination ) : IMessageConsumer
Session::CreateConsumer ( IDestination destination, string selector ) : IMessageConsumer