Example #1
0
        public void TestCtor()
        {
            MessageDispatchChannel channel = new MessageDispatchChannel();

            Assert.IsTrue(channel.Running == false);
            Assert.IsTrue(channel.Empty == true);
            Assert.IsTrue(channel.Count == 0);
            Assert.IsTrue(channel.Closed == false);
        }
Example #2
0
        public void TestStop()
        {
            MessageDispatchChannel channel = new MessageDispatchChannel();

            channel.Start();
            Assert.IsTrue(channel.Running == true);
            channel.Stop();
            Assert.IsTrue(channel.Running == false);
        }
Example #3
0
        internal void Redispatch(MessageDispatchChannel channel)
        {
            MessageDispatch[] messages = channel.RemoveAll();
            System.Array.Reverse(messages);

            foreach (MessageDispatch message in messages)
            {
                this.executor.ExecuteFirst(message);
            }
        }
Example #4
0
        internal void Redispatch(MessageDispatchChannel channel)
        {
            var messages = channel.EnqueueAll();

            Array.Reverse(messages);

            foreach (var message in messages)
            {
                Tracer.Warn($"Resending Message Dispatch: {message}");
                Executor.ExecuteFirst(message);
            }
        }
        internal void Redispatch(MessageDispatchChannel channel)
        {
            MessageDispatch[] messages = channel.RemoveAll();
            System.Array.Reverse(messages);

            foreach (MessageDispatch message in messages)
            {
                if (Tracer.IsDebugEnabled)
                {
                    Tracer.DebugFormat("Resending Message Dispatch: ", message.ToString());
                }
                this.executor.ExecuteFirst(message);
            }
        }
Example #6
0
        public SessionExecutor(Session session, IDictionary consumers)
        {
            this.session = session;
            this.consumers = consumers;

            if(this.session.Connection != null && this.session.Connection.MessagePrioritySupported)
            {
               this.messageQueue = new SimplePriorityMessageDispatchChannel();
            }
            else
            {
                this.messageQueue = new FifoMessageDispatchChannel();
            }
        }
        public void TestEnqueue()
        {
            MessageDispatchChannel channel   = new MessageDispatchChannel();
            MessageDispatch        dispatch1 = new MessageDispatch();
            MessageDispatch        dispatch2 = new MessageDispatch();

            Assert.IsTrue(channel.Empty == true);
            Assert.IsTrue(channel.Count == 0);

            channel.Enqueue(dispatch1);

            Assert.IsTrue(channel.Empty == false);
            Assert.IsTrue(channel.Count == 1);

            channel.Enqueue(dispatch2);

            Assert.IsTrue(channel.Empty == false);
            Assert.IsTrue(channel.Count == 2);
        }
        public void TestRemoveAll()
        {
            MessageDispatchChannel channel = new MessageDispatchChannel();

            MessageDispatch dispatch1 = new MessageDispatch();
            MessageDispatch dispatch2 = new MessageDispatch();
            MessageDispatch dispatch3 = new MessageDispatch();

            channel.Enqueue(dispatch1);
            channel.Enqueue(dispatch2);
            channel.Enqueue(dispatch3);

            channel.Start();
            Assert.IsTrue(channel.Running == true);
            Assert.IsTrue(channel.Empty == false);
            Assert.IsTrue(channel.Count == 3);
            Assert.IsTrue(channel.RemoveAll().Length == 3);
            Assert.IsTrue(channel.Count == 0);
            Assert.IsTrue(channel.Empty == true);
        }
        public void TestEnqueueFront()
        {
            MessageDispatchChannel channel   = new MessageDispatchChannel();
            MessageDispatch        dispatch1 = new MessageDispatch();
            MessageDispatch        dispatch2 = new MessageDispatch();

            channel.Start();

            Assert.IsTrue(channel.Empty == true);
            Assert.IsTrue(channel.Count == 0);

            channel.EnqueueFirst(dispatch1);

            Assert.IsTrue(channel.Empty == false);
            Assert.IsTrue(channel.Count == 1);

            channel.EnqueueFirst(dispatch2);

            Assert.IsTrue(channel.Empty == false);
            Assert.IsTrue(channel.Count == 2);

            Assert.IsTrue(channel.DequeueNoWait() == dispatch2);
            Assert.IsTrue(channel.DequeueNoWait() == dispatch1);
        }
Example #10
0
        internal void Redispatch(MessageDispatchChannel channel)
        {
            MessageDispatch[] messages = channel.RemoveAll();
            System.Array.Reverse(messages);

            foreach(MessageDispatch message in messages)
            {
                this.executor.ExecuteFirst(message);
            }
        }
Example #11
0
		// Constructor internal to prevent clients from creating an instance.
		internal MessageConsumer(Session session, ConsumerId id, ActiveMQDestination destination,
								 String name, String selector, int prefetch, int maxPendingMessageCount,
								 bool noLocal, bool browser, bool dispatchAsync )
		{
			if(destination == null)
			{
				throw new InvalidDestinationException("Consumer cannot receive on Null Destinations.");
            }
            else if(destination.PhysicalName == null)
            {
                throw new InvalidDestinationException("The destination object was not given a physical name.");
            }
            else if (destination.IsTemporary)
            {
                String physicalName = destination.PhysicalName;

                if(String.IsNullOrEmpty(physicalName))
                {
                    throw new InvalidDestinationException("Physical name of Destination should be valid: " + destination);
                }
    
                String connectionID = session.Connection.ConnectionId.Value;

                if(physicalName.IndexOf(connectionID) < 0)
                {
                    throw new InvalidDestinationException("Cannot use a Temporary destination from another Connection");
                }
    
                if(!session.Connection.IsTempDestinationActive(destination as ActiveMQTempDestination))
                {
                    throw new InvalidDestinationException("Cannot use a Temporary destination that has been deleted");
                }
            }

			this.session = session;
			this.redeliveryPolicy = this.session.Connection.RedeliveryPolicy;
			this.messageTransformation = this.session.Connection.MessageTransformation;

			if(session.Connection.MessagePrioritySupported)
			{
				this.unconsumedMessages = new SimplePriorityMessageDispatchChannel();
			}
			else
			{
				this.unconsumedMessages = new FifoMessageDispatchChannel();
			}

			this.info = new ConsumerInfo();
			this.info.ConsumerId = id;
			this.info.Destination = destination;
			this.info.SubscriptionName = name;
			this.info.Selector = selector;
			this.info.PrefetchSize = prefetch;
			this.info.MaximumPendingMessageLimit = maxPendingMessageCount;
			this.info.NoLocal = noLocal;
			this.info.Browser = browser;
			this.info.DispatchAsync = dispatchAsync;
			this.info.Retroactive = session.Retroactive;
			this.info.Exclusive = session.Exclusive;
			this.info.Priority = session.Priority;

			// If the destination contained a URI query, then use it to set public properties
			// on the ConsumerInfo
			if(destination.Options != null)
			{
				// Get options prefixed with "consumer.*"
				StringDictionary options = URISupport.GetProperties(destination.Options, "consumer.");
				// Extract out custom extension options "consumer.nms.*"
				StringDictionary customConsumerOptions = URISupport.ExtractProperties(options, "nms.");

				URISupport.SetProperties(this.info, options);
				URISupport.SetProperties(this, customConsumerOptions, "nms.");
			}
		}
Example #12
0
        // Constructor internal to prevent clients from creating an instance.
        internal MessageConsumer(Session session, ConsumerId id, ActiveMQDestination destination,
								 String name, String selector, int prefetch, int maxPendingMessageCount,
								 bool noLocal, bool browser, bool dispatchAsync )
        {
            if(destination == null)
            {
                throw new InvalidDestinationException("Consumer cannot receive on Null Destinations.");
            }

            this.session = session;
            this.redeliveryPolicy = this.session.Connection.RedeliveryPolicy;
            this.messageTransformation = this.session.Connection.MessageTransformation;

            if(session.Connection.MessagePrioritySupported)
            {
                this.unconsumedMessages = new SimplePriorityMessageDispatchChannel();
            }
            else
            {
                this.unconsumedMessages = new FifoMessageDispatchChannel();
            }

            this.info = new ConsumerInfo();
            this.info.ConsumerId = id;
            this.info.Destination = destination;
            this.info.SubscriptionName = name;
            this.info.Selector = selector;
            this.info.PrefetchSize = prefetch;
            this.info.MaximumPendingMessageLimit = maxPendingMessageCount;
            this.info.NoLocal = noLocal;
            this.info.Browser = browser;
            this.info.DispatchAsync = dispatchAsync;
            this.info.Retroactive = session.Retroactive;
            this.info.Exclusive = session.Exclusive;
            this.info.Priority = session.Priority;

            // If the destination contained a URI query, then use it to set public properties
            // on the ConsumerInfo
            if(destination.Options != null)
            {
                // Get options prefixed with "consumer.*"
                StringDictionary options = URISupport.GetProperties(destination.Options, "consumer.");
                // Extract out custom extension options "consumer.nms.*"
                StringDictionary customConsumerOptions = URISupport.ExtractProperties(options, "nms.");

                URISupport.SetProperties(this.info, options);
                URISupport.SetProperties(this, customConsumerOptions, "nms.");
            }
        }
Example #13
0
 public SessionExecutor(Session session, IDictionary consumers)
 {
     this.session      = session;
     this.consumers    = consumers;
     this.messageQueue = new FifoMessageDispatchChannel();
 }