public IMessageConsumer CreateConsumer()

in src/main/csharp/Session.cs [412:459]


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

			int prefetchSize = this.Connection.PrefetchPolicy.DurableTopicPrefetch;

			if(destination.IsTopic)
			{
				prefetchSize = this.connection.PrefetchPolicy.TopicPrefetch;
			}
			else if(destination.IsQueue)
			{
				prefetchSize = this.connection.PrefetchPolicy.QueuePrefetch;
			}
			
            MessageConsumer consumer = null;

            try
            {
	            Destination dest = destination as Destination;
				consumer = new MessageConsumer(this, GetNextConsumerId(), dest, null, selector, prefetchSize, noLocal);
                consumer.ConsumerTransformer = this.ConsumerTransformer;
				this.AddConsumer(consumer);

				// lets register the consumer first in case we start dispatching messages immediately
				this.Connection.SyncRequest(consumer.ConsumerInfo);

				if(this.Started)
                {
                    consumer.Start();
                }
            }
            catch(Exception)
            {
                if(consumer != null)
                {
					this.RemoveConsumer(consumer);
                    consumer.Close();
                }

                throw;
            }

			return consumer;
		}