Apache.NMS.ActiveMQ.MessageConsumer.Close C# (CSharp) Method

Close() public method

public Close ( ) : void
return void
        public void Close()
        {
            if(!this.unconsumedMessages.Closed)
            {
                if(this.session.IsTransacted && this.session.TransactionContext.InTransaction)
                {
                    this.session.TransactionContext.AddSynchronization(new ConsumerCloseSynchronization(this));
                }
                else
                {
                    this.DoClose();
                }
            }
        }

Usage Example

        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);
        }
All Usage Examples Of Apache.NMS.ActiveMQ.MessageConsumer::Close