Start() public method

public Start ( ) : void
return void
Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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.IsTopic)
            {
                prefetchSize = this.connection.PrefetchPolicy.TopicPrefetch;
            }
            else if (dest.IsQueue)
            {
                prefetchSize = this.connection.PrefetchPolicy.QueuePrefetch;
            }

            MessageConsumer consumer = null;

            try
            {
                consumer = DoCreateMessageConsumer(GetNextConsumerId(), dest, null, selector, prefetchSize,
                                                   this.connection.PrefetchPolicy.MaximumPendingMessageLimit,
                                                   noLocal);

                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);
                    consumer.Close();
                }

                throw;
            }

            return(consumer);
        }
Exemplo n.º 3
0
        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");
            }

            if (IsIndividualAcknowledge)
            {
                throw new NMSException("Cannot create a durable consumer for a session that is using " +
                                       "Individual Acknowledgement mode.");
            }

            ActiveMQDestination dest     = ActiveMQDestination.Transform(destination);
            MessageConsumer     consumer = null;

            try
            {
                consumer = DoCreateMessageConsumer(GetNextConsumerId(), dest, name, selector,
                                                   this.connection.PrefetchPolicy.DurableTopicPrefetch,
                                                   this.connection.PrefetchPolicy.MaximumPendingMessageLimit,
                                                   noLocal);

                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);
                    consumer.Close();
                }

                throw;
            }

            return(consumer);
        }
Exemplo n.º 4
0
        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");
            }

            ConsumerInfo command    = CreateConsumerInfo(destination, selector);
            ConsumerId   consumerId = command.ConsumerId;

            command.SubscriptionName = name;
            command.NoLocal          = noLocal;
            command.PrefetchSize     = this.connection.PrefetchPolicy.DurableTopicPrefetch;
            MessageConsumer consumer = null;

            // Registered with Connection before we register at the broker.
            connection.addDispatcher(consumerId, this);

            try
            {
                consumer = new MessageConsumer(this, command);
                // lets register the consumer first in case we start dispatching messages immediately
                consumers[consumerId] = consumer;

                if (this.Started)
                {
                    consumer.Start();
                }

                this.connection.SyncRequest(command);
            }
            catch (Exception)
            {
                if (consumer != null)
                {
                    consumer.Close();
                }

                throw;
            }

            return(consumer);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        private MessageConsumer CreateConsumer()
        {
            this.browseDone.Value = false;
            BrowsingMessageConsumer consumer = null;

            if (this.session.Connection.PrefetchPolicy.QueueBrowserPrefetch == 0)
            {
                Tracer.Warn("Attempted to create a Queue Browser with Zero sized prefetch buffer.");
                throw new NMSException("Cannot create a Queue Browser with Zero sized prefetch buffer");
            }

            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);
                    consumer.Close();
                }

                throw;
            }

            return(consumer);
        }
Exemplo n.º 7
0
		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;
		}
Exemplo n.º 8
0
        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;
        }