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

CreateConsumer() private method

private CreateConsumer ( ) : MessageConsumer
return MessageConsumer
        private MessageConsumer CreateConsumer()
        {
            this.browseDone.Value = false;
            BrowsingMessageConsumer consumer = null;

            try
            {
                consumer = new BrowsingMessageConsumer(
                    this, session, this.consumerId, this.destination, null, this.selector,
                    this.session.Connection.PrefetchPolicy.QueueBrowserPrefetch,
                    this.session.Connection.PrefetchPolicy.MaximumPendingMessageLimit,
                    false, true, this.dispatchAsync);

                this.session.AddConsumer(consumer);
                this.session.Connection.SyncRequest(consumer.ConsumerInfo);

                if(this.session.Connection.IsStarted)
                {
                    consumer.Start();
                }
            }
            catch(Exception)
            {
                if(consumer != null)
                {
                    this.session.RemoveConsumer(consumer.ConsumerId);
                    consumer.Close();
                }

                throw;
            }

            return consumer;
        }